Randall R Schulz wrote:
On Tuesday 14 November 2006 06:48, Geoffrey wrote:
TheOldWiseKing wrote:
S A

I found a good solution, here is the command:

ls > file1.txt | cat file1.txt > file2.txt
Not so wise OldWiseKing. :)

I don't know what the pipe is for, but I don't think that will work.
file2.txt will likely end up empty.

No, it won't. When cat is given command-line file name arguments it ignores the standard input.

Yes, sometimes it will.  Do you think I posted without testing it myself?

Results are unreliable. I tried this 10 times, twice file2.txt was empty, the other 8 it contained the same data as file1.txt. Cut and paste from my latest attempt:

rhws -> ls > file1.txt | cat file1.txt > file2.txt
rhws -> ls -l file?.txt
-rw-r--r--  1 esoteric esoteric 14168 Nov 14 10:11 file1.txt
-rw-r--r--  1 esoteric esoteric 14168 Nov 14 10:11 file2.txt

I'll not explain why this happens, but it has to do with the improper use of the pipe symbol. If you research how the command line is parsed you will understand why the results is unrealiable. The bottom line is, you don't want that solution, tee is your friend here.

--
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
 - Benjamin Franklin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to