I have a bash script that is asking a user for input, then passes that variable to a find command. I've tried quoting/escaping the variable every way I know, but it keeps failing.
read -p "Please enter the directory # to check: " MYDIR count=`/usr/bin/find /path/to/$MYDIR -name *.txt -mmin -60 | wc -l` if [ $count != 0 ] then echo "There have been $count txt files created in $MYDIR in the last hour" else echo "There have been no txt files created in the last hour in $MYDIR " fi
When running, I get this:
Please enter the directory # to check: temp_dir /usr/bin/find: paths must precede expression Usage: /usr/bin/find [-H] [-L] [-P] [path...] [expression] There have been no txt files created in the last hour in temp_dir