Why does this not work?
ls *.txt | xargs cat > all.txt
(I want to join the contents of all text files into a single 'all.txt' file.) find with -exec should also work, but I would really like to understand the xargs syntax.
might work a bit better, since it would append to all.txt instead of creating it again after each file.
By the way,
If some of your file names contain ', " or space
In general never run
Consider using GNU Parallel instead:
or if you prefer:
Learn more about GNU Parallel http://www.youtube.com/watch?v=OpaiGYxkSuQ
On the other hand:
This will read from textfiles in your current directory into the all.txt in a subdirectory (not included with
You could also come across a command line length limitation. Part of the reason for using
The use of another path is because, as other answers have pointed out, all.txt is matched by the pattern
Note that if you have any files with
The --null option tells grep to use output separated by a