Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does this case of Bash output redir mean?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I am pondering upon

> file2 < file1 cat

The command executes &quot;cat&quot; on file1 and redirects
the standard output to file2.
This is another way of writing
&quot;cat file1 > file2&quot;

Can someone fully explain why the first version works at all? No explanation in Bash manuals.

It is the first version reversed with > at the start.

So the standard output is redirected to file2, but as the input to file2 we get &quot;file1 cat&quot;. Why the need for > ?

I looking forward to your reply.
Thank you in advance for your consideration
 
That *does* look weird....

even weirder - look at this

< file1 cat > file2

> file2 cat < file1

cat < file1 > file2

cat > file2 < file1

they all do the same thing.... Mike
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top