LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pass file like list of params to find command (https://www.linuxquestions.org/questions/linux-newbie-8/pass-file-like-list-of-params-to-find-command-4175440326/)

andreqb 12-06-2012 02:20 PM

Pass file like list of params to find command
 
Hi everybody,

I have a list of ids and I need to find all files that contains this ids, the ideia is delete all this files.

This command returns me all files but in the same line:

find . -type f -print0 | fgrep -zFf temp

ps: temp is a file with all ids.

How can I find all files that contains all these ids?

thanksss

hda7 12-06-2012 03:11 PM

Quote:

Originally Posted by andreqb (Post 4844037)
Hi everybody,

I have a list of ids and I need to find all files that contains this ids

By contain I assume you mean that the id is in the contents of the file; you seem to be checking for the id in the file name. If you mean to search for the ids in the contents of the files, try the following:
Code:

find . -type f -execdir fgrep -lf temp '{}' ';'
This will, for every file in the directory, call
Code:

fgrep -lf temp <filename>
The -l says to print out the name of the file if, and only if, it matches one of the patterns in temp; no other output is generated.

As a side note, "fgrep" is the same as "grep -F", rendering a second -F unnecessary.


All times are GMT -5. The time now is 04:38 AM.