I have hundreds of files in one directory, is there a simple command or pipes of command I can use to append them together? I don't want to use any loops.
|
feedback
|
migrated from stackoverflow.com Jun 12 '11 at 21:24
This question came from our site for professional and enthusiast programmers.
don't do
because "toall.txt" is created before cat is started and you will get strange result, "cat"ing toall.txt into toall.txt. if want cat in the current directory, you should use
.dotted_file is not expanded by or for example
| |||
|
feedback
|
|
If there aren't too many files:
Otherwise:
| |||||||||||||
feedback
|
|
Similar to Ignatio's suggestion:
Without using xargs, you're apt to blow your maximum command line length. Without using -print0, you'll potentially have problems with files that have weird chars (like spaces) in the names. But that's also GNU-specific. | |||
|
feedback
|
|
This will append all files to outfile:
You need to delete outfile first if it exists. This will however not catch the dot-files. If you want to catch those as well you can use the two patterns
to create your file list. It requires a dot-file to have at least length 3, hence excludes . and ..! | ||||
|
feedback
|
catprocesses. – grawity Jun 13 '11 at 13:58