Shell does not like spaces in names. However, over the years, Unix has come up with some tricks to help:
$ find . -name "Chapters*.txt" -type f -print0 | xargs -0 cat >> final_file.txt
You can do what you want.
find recursively finds all directory entries in the file tree that match the query (in this case, the type must be a file, and the name matches the Chapter*.txt template).
Normally, find separates the names of entries in the directory with NL, but -print0 says to separate the names of entries with the NUL . NL is a valid character in the file name, but NUL not.
The xargs command prints the result of find and processes it. xargs collects all the names and passes them in bulk to the command you give it - in this case, the cat .
Usually xargs selects files by space, which means that Chapters will be one file, and 01-05.txt - another. However, -0 tells xargs use NUL as a file separator - this is what -print0 does.
source share