I am using CentOS 6.4 final in two machines. I am executing a script.
The script contains the find
command
path=$1
searchstring=$2
echo `find $path -name $searchString`
for filename in `find $path -name $searchString`
do
echo "$filename"
echo
done
./findfiles.sh /var/log/ *.txt
The above script is executing fine and printing the files. But in the second machine I am getting usage error: find: paths must precede expression
The reason behind is *.txt which got expanded in find command.After changing
for filename in find $path -name "$searchString"
it is executing fine.
Why syntax error is not happening in first CentOS machine?