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?

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

1 Answer 1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .