this one-line shell script not working on Mac - any ideas how to fix?

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



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.

Need Your Help

ExpandableListActivity get Text


I have ExpandableListActivity with Text in each item.

HttpWebRequest GetResponse delay on 64bit Windows

.net 64bit httpwebrequest

I recently tried running a .NET application on 64bit versions of Windows and was surprised to notice that all my HttpWebRequest.GetResponse() calls to web services on my local network were talking ...