-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2143
koalaman edited this page May 17, 2014
·
7 revisions
if [ "$(find . | grep 'IMG[0-9]')" ]
then
echo "Images found"
fi
if find . | grep -q 'IMG[0-9]'
then
echo "Images found"
fi
The problematic code has to iterate the entire directory and read all matching lines into memory before making a decision.
The correct code is cleaner and stops at the first matching line, avoiding both iterating the rest of the directory and reading data into memory.
None.