Difference between 'cat < file.txt' and 'echo < file.txt'

Why doesn't the input redirection work with echo but works with cat?

Because the echo command doesn't accept anything from stdin like cat does, it accepts only parameters.

From man cat:

cat - concatenate files and print on the standard output

Synopsis

cat [OPTION]... [FILE]...

Description

Concatenate FILE(s), or standard input, to standard output.

From man echo:

echo - display a line of text

Synopsis

echo [SHORT-OPTION]... [STRING]...

echo LONG-OPTION

Description

Echo the STRING(s) to standard output.

(emphasis mine)


You can use echo to read the file.txt( not to redirect ) as follows:

echo "$(<file.txt)"

Sample output :

abcdef