madd has asked for the wisdom of the Perl Monks concerning the following question:
are the input, data and output files respectively. I wish to delete the data files of jobs that did not terminate normally (i.e. jobs where the output does not end in "Normal termination"). The following script, using backticks works, but I'm not sure I've done it in the best way. Mainly, I'm concerned about using backticks twice each iteration. I'd appreciate any advice on whether the backticks really are a problem, and if so, how I could better write this script. Thanks in advance, MaddKick0000.inp Kick0000.data Kick0000.log
#!/usr/bin/perl -s $prefix="Kick"; $Restart="Restart.data"; open (RESTART,"$Restart") or die "Unable to open $Restart for reading\ +n"; $AlreadyDone = <RESTART>; $jobs_run= sprintf '%04d',($AlreadyDone); for (my $j=0;$j<=$jobs_run;$j++) { $job_no=sprintf '%04d',($j); $job_title="$prefix$job_no"; $job_end=`tail -n 1 $job_title.log`; if($job_end !~ /Normal/) { `rm $job_title.data`; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Efficient deletion of files / shell interaction
by Corion (Patriarch) on Jul 19, 2009 at 16:06 UTC | |
by madd (Acolyte) on Jul 19, 2009 at 16:34 UTC | |
by Your Mother (Archbishop) on Jul 19, 2009 at 17:17 UTC | |
by Corion (Patriarch) on Jul 19, 2009 at 16:49 UTC | |
by graff (Chancellor) on Jul 19, 2009 at 20:30 UTC | |
|
Re: Efficient deletion of files / shell interaction
by kyle (Abbot) on Jul 19, 2009 at 17:55 UTC | |
|
Re: Efficient deletion of files / shell interaction
by JavaFan (Canon) on Jul 19, 2009 at 18:58 UTC | |
|
Re: Efficient deletion of files / shell interaction
by psini (Deacon) on Jul 19, 2009 at 16:09 UTC |