unix - how to deal with too many args for cat
Question
I have a bunch of files in a directory, each with one line of text. I want to cat all of these files together (all the one liners) into a single, large file. However, when I use cat
there are too many arguments. How can I get around this?
Solution
bash$ (ls | xargs cat) > /tmp/some_big_file
OTHER TIPS
look into xargs
find . <whatever> | xargs cat > outfile.txt
Replace the find . <whatever>
bit with your own way of getting all the files
Replace outfile.txt with your output file.
try to use -n with xargs to reduce the number of arguments passed to cat
find .|xargs -n 100 cat >> out
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow