bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: limiting the directory to locate and search by file type


From: James Youngman
Subject: Re: limiting the directory to locate and search by file type
Date: Mon, 7 Nov 2011 23:47:24 +0000

On Mon, Nov 7, 2011 at 10:02 PM, Peng Yu <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]