The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 08-23-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally posted by oombera
Wow - I tried
(ls * | xargs cat) > all

It works the same and it's cool that it's so small.. but I keep getting the error:

cat: input/output files 'all' identical

The large file is created like it should be, but is there something additional to get rid of / suppress this error?
Ouch! First, that line has the same problem that your original solution did, we are asking the shell to replace * with a list of all files in the current directory. And that won't fly with 5,300 files. What I meant to type is:

(ls | xargs cat) > all

I also didn't think about the output file popping into existence before the ls ran. The best solution for that is something like:

(ls | xargs cat) > /some/dir/all

cat is smart enough to catch this, but grep isn't. And I'm still thinking that the op wanted to use grep to extract certain lines.