Clarity in lesson Redirecting Input and Output

This is in reference to the lesson Redirecting Input and Output.

After completing all the lessons and taking notes, with the notes in front of me I seem to continually run into the same issue so I feel I must not be understanding the lesson.

The ‘echo’ command is only discussed briefly in the leaders to the practical lesson. It is not used in the practical lesson (only cat is used), so I found it difficult to choose the correct responses on the quiz where ‘echo’ is used. My understanding is now that echo references contents of a string and cat references the contents of a file. Is this correct?

In the practical lesson, the command “sort greatest.txt” displays the contents of a file alphabetically. However, the quiz asks for a different string: ‘cat greatest.txt | sort’. This format was not used in the lesson; why does the lesson use the quiz to expose me to a different format?

The “head” (and “tail”) command is used in the practical, but never defined. It confounded me why I would be using this command but then need to look up its definition in a separate platform. Though I understand I must have an appreciation for being exposed to many concepts within the lesson, I also felt there was a certain element of uselessness and distraction to have a command tossed in there that lacked any definition or context.

2 Likes

A pipe | reads stdin of the left side and writes to stdout of the right side.
From there you can read the manual pages of those programs to find out where they read/write and whether they might read/write in different places in different situations.

$ man cat

If you read the man page for cat you’ll find its primary purpose and namesake is concatenation. Concatenating a single piece of text is just repeating it, and that is often redundant.

$ echo blueberries | cat | cat | cat | cat | cat

Same for the other commands, read their man pages. It says there how they behave.

2 Likes

Awesome tip! Thanks!

I feel this should be in the lesson :slight_smile: