Re: How to use locate and exclude certain strings?

Startseite
Anhänge:
Nachricht
+ (text/plain)
Nachricht löschen
Nachricht beantworten
Autor: Brian Cluff
Datum:  
To: Main PLUG discussion list
Betreff: Re: How to use locate and exclude certain strings?
Perhaps you can do what you want by limiting your locate search more and
possibly putting more than one search on the line.
Your locate line would be written better as:

locate /home/joe/mydata/*$file*

you can put more than one search pattern on the same command so if you
really just want to look in a couple of directories you could do:

locate /home/joe/mydata/dir1/*$file* /home/joe/mydata/dir2/*$file*
same thing only cleaner:
locate /home/joe/mydata/{dir1,dir2}/*$file*

if you really want to do an, "everything except a certain thing"
command, you can do:

locate /home/joe/mydata/*$file* |grep -v 'not_this'

Brian Cluff

On 12/23/2014 02:20 PM, wrote:
> I use the following command to locate all files that contain a specified
> string (i.e. $FILE) within a specified directory:
>
> locate $FILE | fgrep -ya "/home/joe/mydata"
>
> How can I modify that command to do the same thing, except exclude all
> paths that contain another specified string?
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss