in reply to system call in Perl
And of course, an all-command-line solution could be made easier by avoiding "awk":# use an all-perl approach: opendir( DIR, "." ); @files = sort {$b cmp $a} grep /BC.*?\.txt$/, readdir DIR; close DIR; open( OUT, ">BCfile.name" ); for ( grep !/Liver/, @files ) { s/\..*/\n/; print OUT; } close OUT; # OR... a little bit of reliance on a sub-shell is okay too; # the next four lines do the same thing just as well: @files = map {s/\..*//; $_} grep !/Liver/, `ls -r *BC*.txt`; open OUT, ">BCfile.name"; print OUT join "", @files; close OUT;
(Look Ma! No quotes!)ls -r *BC*.txt | grep -v Liver | cut -f1 -d. > BCfile.name
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: system call in Perl
by blue_cowdawg (Monsignor) on Jul 11, 2003 at 15:38 UTC |