I have a shell script which outputs all of the .js and .html files found in a folder provided by the user. I need to exclude a sub-folder and all its files from the search results. I'm using the find
command to do this. The command I have currently excludes all the files under this sub-folder but outputs the sub-folder in results. I want to exclude a folder called "CrashLog" and all its files. The path to this sub-folder is "Users/test/Desktop/Units/JSunit/CrashLog/"
Here is the find command I'm using:
find "Users/test/Desktop/Units" -name CrashLog -prune -o -name "*.html" -o -name "*.js"
The output includes "Users/test/Desktop/Units/JSunit/CrashLog/". How can I exclude this? I know I can use grep, but would prefer if there is solution using find itself. I'm running on Mac OSX.
You need -print
, at the end and parenthesis around the file extension tests:
find "Users/test/Desktop/Units" -name CrashLog -prune -o \( -name "*.html" -o -name "*.js" \) -print
find "Users/test/Desktop/Units" -name CrashLog -prune -a \( -name "*.html" -o -name "*.js" \)
-print
is implied. I tend to always supply it ... I guess I wasn't being completely retro about that after all .. - DigitalRoss 2012-04-05 04:26