Running a script with all files in a folder

Hi

I have many files in a folder (like 200) and I want to run a Perl script through all of them. One way would be to do it one by one (which will take forever). But I am sure there is a faster way of doing it.

So inside the folder i have files named in no particular way

eg.
YUI456
YAR234
etc.
etc.

So the perl scrip i am running is like this

perl get-feature.pl rr FILENAME gg OTHERMATCHFILE

the "OTHERMATCHFILE" is the file taht i want to match with all the files inside the folder.

thanks

perl filename.pl *
  • will be expanded by shell with all the filenames in that directoy.

Hi I am having some problems with only using the *

I found an alternative solution but there are some errors.

find ./ -name '*' -exec sh -c 'perl.pl -rr  -ff MATCHFILENAME {} \> {}.txt' \;

basically I want to run each file in the folder through this script then spit out the output file with the .txt ending

...and it would've been helpful if you'd have said so in your original post...

Try something like this:

ls * | grep -v 'txt$' | while read file
do
    perl.pl -rr -ff $file > $file.txt
done