On Mon, Nov 7, 2011 at 10:02 PM, Peng Yu <pengyu...@gmail.com> wrote: > Hi, > > For 'find', I can specify which directory (directories) to perform the > search. It seems that there is no such an option for 'locate' to > restrict the search to certain directory rather than everything in the > database (specified by -d).
You can achieve this by using locate --regex. > Also 'find' offer the option -type, which allows me to search based on > the file type. But I don't see there is a corresponding option in > locate. Correct. > Is my observation correct? Is there a way to do the above two > operations with /locate'? locate --null --regex whatever | xargs --null sh -c 'for file; do test -f "$file" && mycommand "$file"; done' fnord -- This email is intended solely for the use of its addressee, sender, and any readers of a mailing list archive in which it happens to appear. If you have received this email in error, please say or type three times, "I believe in the utility of email disclaimers," and then reply to the author correcting any spellings (and, optionally, any incorrect spellings), accompanying these with humorous jests about the author's parentage. If you are not the addressee, you are nevertheless permitted to both copy and forward this email since without such permissions email systems are unable to transmit email to anybody, intended recipient or not. To those still reading by this point, the author would like to apologise for being unable to maintain a consistent level of humour throughout this disclaimer. Contents may settle during transit. Do not feed the animals.