bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Not so useless use of cat


From: Ralf Goertz
Subject: Not so useless use of cat
Date: Fri, 12 Sep 2014 12:13:28 +0200

Hi,

Why do I need cat (the second on) here?

$ echo first >file1
$ echo second >file2
$ (for i in file[12] ; do cat "$i" > /dev/stdout ; done) | cat > both

$ cat both
first
second

---- 

If I omit the "| cat" after the loop I get

$ cat both
second

Even when using ">> both" instead of "> both" only "second" makes it
into both. Why? I would have thought that using a subshell should be
enough to protect the both from being overwritten. 

Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]