![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing last character from each line of file | cjhancock | Shell Programming and Scripting | 17 | 08-29-2008 01:05 AM |
| removing directory in an input file | chrysSty | UNIX for Dummies Questions & Answers | 2 | 06-04-2008 08:12 PM |
| Removing text from a line in a file | outthere_3 | Shell Programming and Scripting | 10 | 02-13-2008 12:38 AM |
| Removing a particular line from a text file | sendhilmani123 | Shell Programming and Scripting | 5 | 05-31-2006 05:32 AM |
| sed not outputting last line of input file | 2reperry | Shell Programming and Scripting | 3 | 12-16-2005 09:51 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
perl question - removing line from input file
In perl I want to do remove the top line of my input file then process the next line. I want to do something like
head -1 inputfile > temp grep -v temp inputfile > newinputfile cp newinputfile inputfle is this possible in perl? |
| Forum Sponsor | ||
|
|
|
#3
|
|||
|
|||
|
I will give these methods a try. Thanks
|
|
#4
|
|||
|
|||
|
zazzybob,
perl -pi -e '$_ = "" if ( $. == 1 );' large_file I am trying to convert the above perl command line you reference to a script. I am not sure what the -pi does for the command line. But what I have below works but I am wondering if it is efficent or should be done in another manner. $ cat junk #!/usr/bin/perl open (infile, "+< /adsm/ACTIVITIES/CHANGES/TGA2_OBSOLETE_CLNUP/x "); open (outfile,">/adsm/ACTIVITIES/CHANGES/TGA2_OBSOLETE_CLNUP/z"); while ( $line = <infile>) { if ($. == 1) { } else { print (outfile "$line"); } } #end while system ("cp /adsm/ACTIVITIES/CHANGES/TGA2_OBSOLETE_CLNUP/z /adsm/ACTIVITIES/CHANGES/TGA2_OBSOLETE_CLNUP/x"); close(infile); close(outfile); |
|||
| Google The UNIX and Linux Forums |