I have a shell script that used to run find on Ubuntu 10.04 but since I have moved to 12.04 it doesn't work as before throwing the following messages:

/home/checks.sh: 1: /home/checks.sh: date
: not found
find: invalid mode `0777\r'

the script is as follows:

echo ""
echo "Files changed in the last 24 hours"
echo "=================================="
find /var/www -mtime -1 | grep -iv '.log'
echo ""
echo ""
echo "Files with permissions set to 777"
echo "================================="  
find /var/www -perm 0777

all lines work from the command line but not in the shell script any more.

Can't find anything in the manual to suggest why.

1 Answer 1


Your file has windows-style line endings.

Use dos2unix or similar utilities to convert it to Linux line endings, and be careful next time you upload it.

  • Perfect thanks - for others that have the same issue I got this uploading from a Mac, so not just Windows/DOS
    – williamsdb
    Oct 28, 2012 at 10:20

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.