0

I have many folders/subfolders with text files in them. Is there any way to iterate all of the subfolders and join all the files into a single large file?

  • If my answer solved your problem, please accept it by clicking the checkmark next to it. Thank you! – Jeff Schaller Jan 6 at 14:35
1

One simple way:

find /top/level/subdir -type f -exec cat {} + > output

Or using bash features:

shopt -s globstar
cat subdir/** > output 2>/dev/null

The 2>/dev/null redirection drops the complaints about bash trying to cat directories.

  • by output you mean output.txt? – Born vs. Me Dec 31 '18 at 18:24
  • 1
    you didn't specify a filename; you can name it whatever you want! :) – Jeff Schaller Dec 31 '18 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.