← Linux & the Command Line tutorial
Piping & Redirection
The pipe | feeds one command's output straight into
another's input — this is what makes the command line so powerful,
chaining small, focused tools into a bigger one.
Example: filtering and logging
$ ls -la | grep ".txt"
$ echo "Deploy finished" >> deploy.log
The first command lists only files whose names contain ".txt" — the
same grep filtering idea from the previous lesson, applied
to a directory listing instead of a process list. >
redirects output into a file, overwriting whatever was there before;
>> (used above) appends instead, adding a new line to
deploy.log without erasing anything already logged — exactly
the distinction you want when writing to a log file that's supposed to
accumulate history rather than get wiped on every write.
$ ls -la | grep ".txt"
$ echo "Deploy finished" >> deploy.log
The first command lists only files whose names contain ".txt". The second appends a line to deploy.log without erasing what was already there.