On Wed, 12 Jan 2005, JupiterHost.Net wrote: > Saurabh Singhvi wrote: > > HI all, > > Hello, > > > i want to write a perl script in linux that would get the file names > > in the directory i am running it in and then execute a system command > > for each file.(the encoding line). how should i go about it?? > > perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' By which you're basically saying the following non-Perl statement::
$ for file in *; do command "$file"; done Or, as a full shell script: #/bin/sh command=/whatever/you/want for file in * do $command "$file" done But I'm still confused -- why not just forget all this and do a $ command * ? I see no need for Perl *or* shell to solve this, unless the system command in question doesn't know how to take multiple files as input. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>