concatenate files including path in header - path contains spaces
- by manolo
I have to concatenate a number of files in a directory structure which contains spaces in the folder names looking like this: ./CH 0000100014/A10/11XT/11xt#001.csv
find . -name "*.csv" -type f -print0 | xargs -0 cat > allmycsv.txt
does the job, however now I need to include the information contained in the path, i.e. CH 0000100014/A10/11XT as a header of each inputfile to cat.
find . -name "*.csv" -type f -print0 | xargs -0 -I % sh -c 'echo %; cat %' >allmycsv.txt
would do the job, if I had no spaces in the path, but in my case, cat does not get along with the space in the path name. Is there a way out?
Cheers,
E
P.S. I am working on bash on OSX