If you want to concatenate files located in subdirectories as well, you can use the find command in combination with cat. Here's how you can do it:
find /path/to/directory -type f -exec cat {} + > combined.txt
In this command:
- Replace
/path/to/directorywith the path to your main directory. -type fensures that only files are selected.-exec cat {} +executes thecatcommand on all found files.combined.txtis the output file that will contain the concatenated contents of all files found in the directory and its subdirectories.
If you want to concatenate only specific types of files (e.g., all .txt files), you can modify the command like this:
find /path/to/directory -type f -name "*.txt" -exec cat {} + > combined.txt
This will concatenate all .txt files in the specified directory and all its subdirectories into combined.txt.
