> On 10/3/20 12:00 PM, John Ruckstuhl wrote: > > In egrep (grep 3.0), the order of options (multiple --include and > > --exclude), is surprisingly significant. > > I was puzzled by 5 extra output lines in my first egrep, so I did > > another egrep, with the --include moved up front. > > That's expected behavior, but it's not documented and should be. Thanks for > bringing it up. I installed the attached > doc patch.
Thank you for the quick response. I looked at the patch, and for several minutes I was still not comprehending it... But I think I've got it now. This $ egrep -r -i -n -l --exclude="*.bak" --include="*.py" "$PAT" "$DIR" does not map to this find "$DIR" -type f ! -name "*.bak" -name "*.py" | while read F; do egrep -i -n -l "$PAT" "$F"; done It maps to this (with INCFIRST representing "-true" or "-false") find "$DIR" -type f \( \ \( ! -name "*.bak" ! -name "*.py" \) \( \ ! "$INCFIRST" \( -true \) \ -o \ "$INCFIRST" \( ! -name "*.bak" -name "*.py" \) \ \) \ -o \ \( ! -name "*.bak" -name "*.py" \) \ \) | while read F; do egrep -i -n -l "$PAT" "$F"; done Yikes. As it is not yet documented, I'll happily venmo you $50 to consider it a bug instead of an undocumented behavior. Warm regards, Paul. :) John Ruckstuhl johnru@ISIMFGDEV400 /cygdrive/c/Program Files (x86)/foxtrot/EC Test SW (750390-mango) $ egrep -r -i -n -l --exclude="*.bak" --include="*.py" "\.name\b|testname" ISITestFramework | cat -n 1 ISITestFramework/DUT/CameraModule/CameraModule/CameraModule.py 2 ISITestFramework/DUT/CameraModule/CameraModule/CameraModule_0.py 3 ISITestFramework/DUT/EC/EC.py 4 ISITestFramework/DUT/Endoscope/Endoscope.py 5 ISITestFramework/DUT/GenericDUT.py 6 ISITestFramework/DUT/LightEngine/LightEngine/LightEngine.py !! 7 ISITestFramework/HTML/BatFileUtils.html !! 8 ISITestFramework/HTML/Libs/jquery/1.12.2/jquery.min.js 9 ISITestFramework/IQOQDQUtils.py !! 10 ISITestFramework/Reports/ReportTemplates/Libraries/GoogleChartsJsapi.js !! 11 ISITestFramework/Reports/ReportTemplates/Libraries/jquery-latest.min.js !! 12 ISITestFramework/Reports/ReportTemplates/TestResultsSimple.html 13 ISITestFramework/Reports/ReportTools.py 14 ISITestFramework/Reports/ReportUtils.py 15 ISITestFramework/Reports/SummaryMetricWriter.py 16 ISITestFramework/Test.py 17 ISITestFramework/TestTools.py johnru@ISIMFGDEV400 /cygdrive/c/Program Files (x86)/foxtrot/EC Test SW (750390-mango) $ egrep -r -i -n -l --include="*.py" --exclude="*.bak" "\.name\b|testname" ISITestFramework | cat -n 1 ISITestFramework/DUT/CameraModule/CameraModule/CameraModule.py 2 ISITestFramework/DUT/CameraModule/CameraModule/CameraModule_0.py 3 ISITestFramework/DUT/EC/EC.py 4 ISITestFramework/DUT/Endoscope/Endoscope.py 5 ISITestFramework/DUT/GenericDUT.py 6 ISITestFramework/DUT/LightEngine/LightEngine/LightEngine.py 7 ISITestFramework/IQOQDQUtils.py 8 ISITestFramework/Reports/ReportTools.py 9 ISITestFramework/Reports/ReportUtils.py 10 ISITestFramework/Reports/SummaryMetricWriter.py 11 ISITestFramework/Test.py 12 ISITestFramework/TestTools.py this is the same logic: $ for INCFIRST in -true -false; do > printf "%s: %s\n" "\$INCFIRST" "$INCFIRST" > > # if no --incude or --exclude options match, > # if not INCFIRST then file is included > # if INCFIRST then file is not included > find "$DIR" -type f \( \ > \( ! -name "*.bak" ! -name "*.py" \) \( \ > ! "$INCFIRST" -true \ > -o \ > "$INCFIRST" \( ! -name "*.bak" -name "*.py" \) \ > \) \ > -o \ > \( ! -name "*.bak" -name "*.py" \) \ > \) | > # egrep "\.(html|js)$" > G | wc -l > done $INCFIRST: -true 12 $INCFIRST: -false 17