We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Piping

One of the most beautiful things about the shell is that you can pipe the output of one program into the input of another program. With this one simple concept, you can run incredibly powerful automation tasks.

Pipe

The pipe operator is |. It's the character that looks like a vertical line. It's usually on the same key as the backslash (\) above the enter key. The pipe operator takes the stdout of the program on the left and "pipes" it into the stdin of the program on the right.

echo "Have you heard the tragedy of Darth Plagueis the Wise?" | wc -w
# 10

In the example above, the echo command sends "Have you heard the tragedy of Darth Plagueis the Wise?" to stdout.

However, instead of that text being sent to your terminal, the pipe operator pipes it into the wc (word count) command. The wc command counts the number of words in the input it receives. The -w flag tells wc to only count words.

This only works because the wc command, like most shell commands, can optionally read from stdin instead of a filepath argument.

Assignment

We need to figure out just how many transactions "Bob" has been involved in... Bob's looking sus fr.

  1. grep -R "TEXT_TO_FIND" PATH_TO_TRANSACTIONS_DIR --exclude-dir="DIR_TO_EXCLUDE"
    

Submit the shell checks.

Tip

The answer is 3973. If your number is off, double-check that you used --exclude-dir="backups" (otherwise you'll also count the duplicate transactions in the backups directory) and that you searched the whole transactions directory.