The big idea behind the Unix shell is simple: lots of small programs that each do one job well, joined together so the output of one becomes the input of the next. That joining is done with redirection and pipes, and once it clicks, you'll start solving problems in a single line that would otherwise need a script or a spreadsheet.
This module starts with the three standard streams every
command has: standard input, standard output and standard error (file
descriptors 0, 1 and 2). You'll learn to send output to a file with
>, append with
>>, capture errors with
2>, and combine both with
2>&1. Next comes the
pipe (|) for chaining commands
together, then xargs for turning one command's output into
another command's arguments. The module finishes with
here-documents, which let you feed several lines of text
straight into a command or file.
Type along with each example as you watch the lessons in order, then continue on to Text Processing, where you'll put pipes to work with grep, sed and awk.
An episode of Linux Crash Course on the three data streams every command uses: standard output, standard input and standard error. It shows how to redirect each one so output and errors end up where you want them.
How to join several commands with pipes so the output of one is sent straight into the next. This is how you build longer pipelines from simple tools.
How xargs builds and runs commands by taking the results of one command and passing them as arguments to another. It's the missing piece for commands that don't read from a pipe.
An episode of "anthony explains" on here-documents: a tidy way to pass a block of several lines into a command's standard input, both at the prompt and inside scripts.