Cat filename.txt vs cat < filename.txt

I’m doing the Learn Command line course and I’m not clear on why you would type “cat < filename.txt” instead of just “cat filename.txt” when it outputs the same thing. It’s step 8 of this project:

https://www.codecademy.com/courses/learn-the-command-line/projects/athletica

It’s redundant in this case, but if we look at the definition:

< takes the standard input from the file on the right and inputs it into the program on the left.

we see it’s not quite the same as just output.

Look at this discussion for more background on what you may do with <: https://unix.stackexchange.com/questions/106039/why-does-the-less-than-sign-not-work-as-a-replacement-for-cat-in-bash

2 Likes