Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Removing lines from files

by markkawika (Monk)
on May 09, 2008 at 22:33 UTC ( [id://685789]=note: print w/replies, xml ) Need Help??


in reply to Removing lines from files

Perl is a poor choice for this operation. I would use a bourne shell script with standard unix utilities (assuming you're doing this on a unix box):
#!/bin/sh DIR=$1 cd ${DIR} find . -name '33dc01.*outer?log' -print | \ while read fn do tail +5 ${fn} > ${fn}.deleting mv ${fn}.deleting ${fn} done

Replies are listed 'Best First'.
Re^2: Removing lines from files
by Anonymous Monk on May 13, 2008 at 15:49 UTC
    Using the code below how would I modify it so that only one file gets processed at a time. Meaning make the script wait until file1 is done with the removal/backup/deletion before it starts with file2? thanks again for the help
    #!/usr/bin/perl use warnings; use strict; use File::Find; @ARGV == 1 or die "usage: $0 directory_name\n"; my @files; find sub { if ( -f and /^33dc01\..*outer\.log$/ ) { push @files, $File::Find::name; print "$File::Find::name\n"; } }, $ARGV[ 0 ]; ( $^I, @ARGV ) = ( '', @files ); while ( <> ) { next if $. <= 4; print; close ARGV if eof; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://685789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-09-07 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.