where.sh is a command-line shell script utility that will help you load files with specific regular expression. It starts in the current directory and looks under all subdirectories. It uses the UNIX "find" utility but doesn't require you to remember all of the command-line arguments. In addition, it suppresses all of the error messages that "find" generates. Suppress of the error messages are very helpful on UNIX system where you don't have access to many of the subdirectories. where.sh is distributed as executable source code under the GNU General Public License. Please see the license agreement elsewhere on this site.
where.sh "file name expression"
Locates all files with the "zip" extension.
Locates all raw images in the 7000 series.
Today, I needed to find all UNIX hidden files (starts with a period) in a sub-directory tree. But every time I issued
ls .*, I get back everything all files in the current directory and all files in the parent directory. That is because the mask matches the "." and ".." directory entries as well. Finally, I optimized down to
ls .??*, which weeded out "." and "..", but ignores hidden files with one and two character names.
Eventually, it occurred to me that this where.sh script can easily help me out. And sure enough, issuing
where.sh ".*"on the command line got me exactly what I wanted in mere seconds. Only if I could have thought of it that fast.
I've beefed up the where.sh script so that it does more error checking and remove the writing to a temporary file. In addition, it now accept multiple file masks, to search for, on the command-line.
Usage: where.sh "file mask 1" [ . . . "file mask N" ]
You must surround file masks in double-quotes.
where.sh "*.zip" "CRW_7???.RAW"
Locates all files with the "zip" extension and all raw images in the 7000 series.
Recently, I have installed quite a few virtual machines on my notebook computer. The virtual machines all share common folders, which are mounted via symbolic links. "where.sh" breaks down, because it does not search into symbolic links.
Therefore, I've modified "where.sh" so that it does. The new version is attached below.
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
31 Users Online
Copyright © 1996 - 2019. All Rights Reserved.