Why doesn’t **find** find anything?

Question :

Why doesn’t **find** find anything?,

Answer :

I’m looking for shell scripts files installed on my system, but find doesn’t work:

$ find /usr -name *.sh  

But I know there are a ton of scripts out there. For instance:

$ ls /usr/local/lib/*.sh  /usr/local/lib/tclConfig.sh    /usr/local/lib/tkConfig.sh  

Why doesn’t find work?

,

Try quoting the wildcard:

$ find /usr -name *.sh  

or:

$ find /usr -name '*.sh'  

If you happen to have a file that matches *.sh in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the find command would expand to:

$ find /usr -name tkConfig.sh  

which would only find files named tkConfig.sh. If you had more than one file that matches *.sh, you’d get a syntax error from find:

$ cd /usr/local/lib  $ find /usr -name *.sh  find: bad option tkConfig.sh  find: path-list predicate-list  

Again, the reason is that the wildcard expands to both files:

$ find /usr -name tclConfig.sh tkConfig.sh  

Quoting the wildcard prevents it from being prematurely expanded.

Read More  Debugging JavaScript in Internet Explorer and Safari

Another possibility is that /usr or one of its subdirectories is a symlink. find doesn’t normally follow links, so you might need the -follow option:

$ find /usr -follow -name '*.sh'  

That’s the answer Why doesn’t **find** find anything?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  Getting notified when the page DOM has loaded (but before window.onload)