I have hundreds of folders with a few text files in each folder. I'm trying to concatenate the files of each folder into a single text file. One file for each folder. Ideally, the concatenated files would be saved to another location.
You can do with a simple script:
#!/bin/bash directories="/your/path/dir1 /your/path/dir2 /your/path/dir3" for d in $directories do cat $(find $d -name "*.txt") > $(echo $d | sed 's/\///g').txt done
This script will concatenate every txt file on
/your/path/dir1 and saves it as
yourpathdir1.txt in your actual path. Then will do the same with