0

I am struggling a bit with my bash find command.

The problem is a late requirement which wants me to strip off all records from *.app files containing *.appstrng"

This is my original find pipeline that is working flawlessly without the negative attempt to strip records:

find . -type f -iname "*.app" -exec grep -we selected_apps -e app_name --color=auto --with-filename {}         \; > LOG.txt

Now here are some of the attempts I have made to add stripping of .appstring before creating LOG.txt

1) With grep -v

find . -type f -iname "*.app" -exec grep -we selected_apps -e app_name -ev "*.appstring" --color=auto --with-filename {} \; > LOG.txt

2) With awk

find . -type f -iname "*.app" -exec grep -we selected_apps --color=auto --with-filename {} \; | awk '!/*.appstring/' > LOG.txt

I am not sure if find/grep or find/awk will even work in this way... all comments welcomed! Thanks!!

  • Thanks but... 1) if this is 'global' wont the positive, original search also be effected. 2) I am not sure how this would be added to the full pipe? very new here. Thx. – SSDdude Aug 2 '18 at 15:39
0

You can use your original command and remove some results with an additional command:

cat LOG.txt | while read FILE; do
    if ! grep -q "*.appstring" "$FILE"; then
        echo $FILE >> LOG-filtered.txt
    fi
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.