I am using 2 machine , which is both Red Hat Enterprise Linux AS release 3 (Taroon Update 2) ( I check it in /etc/*-release ).
I checked they are using the same default shell by ps -p $$
, which is bash.
I tried to execute a find command with wildcard pattern: find path -name pattern -type f -ctime +3
and the pattern contain * character as wildcard.
The first machine seems to expanded the wildcard character and causing error:
find /home/primbat/testing -name sftp_bcs_report_*.log -type f -ctime +7
find: paths must precede expression
and I need to either make the pattern in between 2 delimited qoute, e.g: \"sftp_bcs_report_*.log\"
or using set -f
in the script to suppress wildcard expansion.
Which in the other machine, it have no such problem. Do you have any idea?
echo find /home/primbat/testing -name sftp_bcs_report_*.log -type f -ctime +7
. It is clear that your shell is expanding the wildcard and, as you have two or more files matching the wildcard, the second one gets caught byfind
as an out-of-place path parameter. Please note that you're lucky you have more than one file under that wildcard in the current directory, otherwisefind
would just accept the expanded wildcard silently!