Kipp, James wrote:
> > > > perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt
> > > 
> 
> Bob
> I have been trying to figure out a different solution then using the
> -i arg. Is there a simple way to just open each file, delete the 5
> lines in place and close it(with no backup file), without getting
> into sysread, truncate, etc...

Not really. What's the problem with using -i?

> 
> something like this:
> 
> @files = glob("*.ps");
> foreach $file (@files) {
>       open (IN, "$file") or die "can't open $!\n";
>       while ($line = <IN>) {
>               $line =~ s/.*\n// if $. <= 5;
> }
> close IN;
> 
> -----
> I can't seem to delete the lines in place, without using -i, I was
> able to do it easily with a shells script using sed:
> 
> cd dir_with_the_files
> for file in `ls .`
> do
>         sed '1,5d' $file > $file
> done

Really? did you actually try that? The shell will clobber the file before
sed gets a chance to open it. I don't see how you could wind up with
anything but an empty file.

FWIW, FreeBSD's sed has a -i option a la Perl's. Maybe Linux and other newer
Unices have that as well?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to