count=`ls *.php -l | wc -l`
if [ "$count" -ne "0" ]; then
mv *.php ~/Desktop/PHP
echo "moved $count php files"
echo "$count php files found"
With this code I am attempting to ensure a php file exists, then attempting to move it to another folder. My script has 40 or so extensions, this is one of many. My problem is this: if the current folder contains no php files i receive an error.
ls: cannot access *.php: No such file or directory
Typically I would use 2> /dev/null to handle output suppression but in this case it prevents the variable assignments. Any help would be appreciated.