Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input redirection to echo

Tags:

linux

io

echo

I'm fairly new to bash/linux and was trying to do the following:

echo < test.txt

where test.txt just contains a bunch of text. The problem is this just prints a blank line to the terminal output.

I understand I could just use cat but I'm trying to understand why redirecting input to echo isn't working.

like image 973
V_TS Avatar asked Sep 02 '25 04:09

V_TS


1 Answers

echo < test.txt

Will not work because echo operates on a format string, not redirected file input (i.e. stdin). What you want is cat

cat test.txt

cat short for concatenate will cat test.txt to stdout. note: its companion tac will write test.txt to stdout in reverse.

like image 63
David C. Rankin Avatar answered Sep 04 '25 18:09

David C. Rankin