Reputation: 34838
This unix command I haven't got quite working on Mac yet - any ideas what needs adjusting:
find . | grep '.*\(css\|js\|rjs\|rhtml\|rb\)$' | sort | while read in; do printf "\n\n####\n# FILE: %s\n####\n\n" ${in} >> onebigfile; cat "${in}" >> onebigfile; done
thanks
Upvotes: 0
Views: 335
Reputation: 37477
The purpose of this command is to gather the content of all the files under the current directory whose names ends as said (css ... rb) in a file named onebigfile (with delimiters) IIUC.
To debug this type of series of piped commands, you can run the individual commands, or individual groups of commands to try to see what is happening. For instance, try:
find .
find . | grep '.*\(css\|js\|rjs\|rhtml\|rb\)$'
find . | grep '.*\(css\|js\|rjs\|rhtml\|rb\)$' | sort
Then get one line of the output (for example ./dir/file.css), and try:
echo './dir/file.css' | while read in; do echo ${in}; done
echo './dir/file.css' | while read in; do cat ${in}; done
echo './dir/file.css' | while read in; do cat ${in} >> onebigfile; done
You should bo able then to understand what's happening.
The problem may be due to file and directory names containing spaces. The solution in this case is to use find -print0
command.
Upvotes: 2