Reputation: 303
on my Red Hat server I have a script inside the /root/ folder that performs some operations based on the contents of some folders. In particular
find /PATH/TO_TEST/ -type f -name *.war
→ search for war files from a certain folderfind /PATH/TO_TEST/ -type d -name jobs
→ look for a folder with a certain name from a certain folderUntil yesterday everything worked properly, today a very strange thing happened (strange things happen at Hogwarts)
Command 2 works normally.
Command 1 only works if I DO NOT run it from within the /root/
directory
That is if I execute the command while I'm in /root/
, the find command doesn't give results while if I go out from /root/
folder and go to any other folder the find command finds the files I'm looking for.
The path I look for is absolute, so the "where do I run the find command" should have no difference and HOWEVER, until yesterday it has regularly worked from inside the /root/
directory.
on other similar vm everything works as it normally should.
The version of find command and the SO are the same in all VM.
Upvotes: 1
Views: 117
Reputation: 361546
Quote '*.war'
to prevent the shell from expanding it:
find /PATH/TO_TEST/ -type f -name '*.war'
When it's unquoted, if there happens to be a *.war
file in the current directory the shell will expand *.war
to the name of that file. You want find
to expand the glob, not the shell.
I'm guessing some .war
file was recently dropped into /root
. If there's a file foobar.war
the unquoted version will expand to this terrible, horrible, no good, very bad command:
find /PATH/TO_TEST/ -type f -name foobar.war
Upvotes: 1