how to batch 'find' ?

I have a file with about 600 pattern expressions and/or filenames. I want to use the command ‘find’ to locate all occurences for those patterns and redirect/output the results into another file.
But whatever i’ve tried failed lamentably :’(. So anyone can help ?

Do it a different way. Generate all the filenames in the tree, and then pipe them through grep -f patternfile. You will have to work out how to make the patterns match only the filename portion while outputing the whole path.

You are right, i could try it that way. My patterns can only matches one file by pattern, so it won’t be a problem there.
Thanks.
(ps: it is very time consuming.)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, what have you tried? What patterns? Which files? You could
create an array of patterns and loop through them with a ‘for’ loop
easily enough… For example to go for a few different file
extensions that were case-insensitive in their matching…

<quote>
#!/bin/bash
declare -a patterns=(‘ods’ ‘xml’ ‘odt’)
for i in echo ${patterns[li]}; do[/li]find /starting/path/here -iname *.$i >>/path/goes/here/outputfile.txt
done
</quote>

Good luck.

hotus wrote:
> I have a file with about 600 pattern expressions and/or filenames. I
> want to use the command ‘find’ to locate all occurences for those
> patterns and redirect/output the results into another file.
> But whatever i’ve tried failed lamentably :’(. So anyone can help ?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJWkqE3s42bA80+9kRAqD4AJoClgkkV5TQHohxiwW6/lptSbb/DwCfdkGD
r0C4/1RgpxFFVXVsEe1/qts=
=I/Mc
-----END PGP SIGNATURE-----

My patterns are dynamically build from ‘grep’ with a regular expression , piped with ‘sed’, ‘sort’ and ‘awk’ (I know, why do it simple… :slight_smile: ). This results in a list of unique filenames which i will manage later.
I tried to avoid using shell script and do all i wanted with a oneline command. That’s where my headaches comes from :shame:.

Thank you guys; I will use ken_yap’s solution.

sorry, double post

Hi you might find this quicker than recursive find’s (no pun intended)

find /path -type f|grep -f ${your_pattern_name_file} > ${your_results_file}

Cheers

Sorry - too late and copying ken’s suggestion.

Forget I ever said anything.

:frowning: