On 08/19/2006 02:19 AM, I BioKid wrote:
I have a simple - yet trivial problem -

I 2000 directory at /home2/foo/foodir/ .
I need to copy all files with extension *.atm and *.ali to another directory
called temp (say  /home2/foo/foodir/temp )
After that I need to run a program in each of this directory - (say joy
*.ali )
If am suppose to do it it will take a hell lot of time - so I have written a
small perl
script - but am not able to get what i need ...
Here is my script :

@a=`cat list`;

What is 'list'?

foreach $a(@a)
       {
       `mkdir $a`;

Why not use Perl's mkdir command?

# it is working fine up to this end -
       `cd $a`;

Why not use Perl's chdir command?

       `cp ../../$a/ *.ali .`;
       `cp ../../$a/ *.atm .`;
       }
am getting error / warning like this

cp: missing destination file
Try `cp --help' for more information.
sh: /: is a directory
but when am doing it manualy all the comments are working fine

Please help me with some inputs -

<OT>
Why use Perl at all?

Assuming that 'list' is a list of *.atm and *.ati files (without path names) in /home2/foo/foodir, you could try this:

cd /home2/foo/foodir/
cat ~/list | xargs -n1 -i cp \{\} /home2/foo/foodir/temp/
cd /home2/foo/foodir/temp
cat ~/list | xargs -n1 joy

WARNING: UNTESTED CODE



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to