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?
For finding files on your disks, lean to use "locate" instead that is instantaneous (looks into a daily built index) you example would be:
Try quoting the wildcard:
or:
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:
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:
Again, the reason is that the wildcard expands to both files:
Quoting the wildcard prevents it from being prematurely expanded.
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:
On some systems (Solaris, for example), there's no default action, so you need to add the -print command.