|if [ -n "$1" ]|
|# Find image files in.|
|FILES=`find $DIR -type f | grep ".*\.\(jpg\|gif\|png\|jpeg\)"`|
|# Default searcher is grep. If Silver Searcher is installed, use that.|
|SEARCHER='grep -r -l '|
|if command -v ag|
|# Sweet! Let's use Silver Searcher.|
|SEARCHER='ag -l '|
|# Loop over image files.|
|for f in $FILES|
|if [[ -f $f ]]|
|found=$($SEARCHER $name $DIR)|
|if [[ -z $found ]]|
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
This works well, except when I'm using Silver Searcher (ag version 0.23.0, installed with homebrew) it outputs the location of ag (/usr/local/bin/ag). So if I pipe to xargs rm, ag is removed and I have to relink. I've played with the script a bit to see if I could fix it, but I'm not familiar with shell scripting. Any thoughts?