Redirecting Input and Output

Learn to redirect input and output to and from files and programs.

Start[missing "en.views.course_landing_page.learn-the-command-line.course_illustration" translation]
Redirection
Lesson 1 of 1
  1. 1

    Up until now, we have run commands in the command line and received a stream of output in the terminal. In this lesson, we'll focus on input and output (I/O) redirection. Through redirection yo...

  2. 2

    What happens when you type this command? [...] The [...] command accepts the string "Hello" as standard input, and echoes the string "Hello" back to the terminal as standard output. Let'...

  3. 3

    How does redirection work? [...] The [...] command redirects the standard output to a file. Here, [...] is entered as the standard input. The standard output [...] is redirected by [...]...

  4. 4

    [...] [...] takes the standard output of the command on the left, and redirects it to the file on the right. Here the standard output of [...] is redirected to continents.txt. Note that...

  5. 5

    [...] [...] takes the standard output of the command on the left and appends (adds) it to the file on the right. You can view the output data of the file with [...] and the filename. Her...

  6. 6

    [...] [...] takes the standard input from the file on the right and inputs it into the program on the left. Here, lakes.txt is the standard input for the [...] command. The standard outp...

  7. 7

    [...] [...] is a "pipe". The [...] takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as "command to co...

  8. 8

    [...] [...] takes the standard input and orders it alphabetically for the standard output. Here, the lakes in [...] are listed in alphabetical order. [...] Here, the command takes the st...

  9. 9

    [...] [...] stands for "unique" and filters out adjacent, duplicate lines in a file. Here [...] filters out duplicates of "Sahara Desert", because the duplicate of 'Sahara Desert' directly f...

  10. 10

    [...] [...] stands for "global regular expression print". It searches files for lines that match a pattern and returns the results. It is also case sensitive. Here, [...] searches for "Mount...

  11. 11

    [...] [...] searches all files in a directory and outputs filenames and lines containing matched results. [...] stands for "recursive". Here [...] searches the **/home/ccuser/workspace/geo...

  12. 12

    [...] [...] stands for "stream editor". It accepts standard input and modifies it based on an expression, before displaying it as output data. It is similar to "find and replace". Let's lo...

  13. 13

    Congratulations! You learned how to use the command line to redirect standard input and standard output. What can we generalize so far? Redirection* reroutes standard input, standard output, an...

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Redirecting Input and Output

Start[missing "en.views.course_landing_page.learn-the-command-line.course_illustration" translation]