delete last row in PERL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete last row in PERL
# 1  
Old 07-01-2010
Question delete last row in PERL

How to delete last row in the file in PERL.

file1 has

Code:
a.output
b.output
c.output
d.output
e.output

expected output is
Code:
a.output
b.output
c.output
d.output

# 2  
Old 07-01-2010
Code:
perl -ne '{push @x, $_}END{pop(@x); print @x}' file1

This User Gave Thanks to pseudocoder For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete row if column matches

Hi, I have a long file in the format below. I want to delete the consecutive lines that contain the same value in column 1. I have tried awk '!x++' FS="," filename This has not worked. 14,MM709_BHP_DM,BHP,BHP_MC709_DM 19,OFFLINE,CHE,CHEV_MC773_DM 20,M33,BP,BP_MIM775_NS_DM ... (2 Replies)
Discussion started by: ndnkyd
2 Replies

2. Shell Programming and Scripting

Delete duplicate row

Hi all, how can delete duplicate files in file form, e.g. $cat file1 aaa 123 234 345 456 bbb 345 345 657 568 ccc 345 768 897 456 aaa 123 234 345 456 ddd 786 784 234 263 ccc 345 768 897 456 aaa 123 234 345 456 ccc 345 768 897 456 then i need ouput file1 some, (4 Replies)
Discussion started by: aav1307
4 Replies

3. Shell Programming and Scripting

Delete a row if either of column value is zero

Hi, My input file is this way 1.1 0.0 2.4 3.5 7.9 1.8 22.3 4.7 8.9 0.9 1.3 0.0 3.4 5.6 0.0 1.1 2.2 0.0 0.0 1.1 0.0 0.0 3.4 5.6 I would like to delete the entire row, if either of 2nd and 3rd columns are 0.0. Please note that my values are all decimal values. So, my output would... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

4. Shell Programming and Scripting

Delete row if a a particular column has more then three characters in it

Hi i have a data like hw:dsfnsmdf:39843 chr2 76219829 51M atatata 51 872389 hw:dsfnsmdf:39853 chr2 76219839 51M65T atatata 51 872389 hw:dsfnsmdf:39863 chr2 76219849 51M atatata 51 872389 hw:dsfnsmdf:39873 chr2 ... (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

5. UNIX for Dummies Questions & Answers

How to delete a row in a file

hi team, i have a file txt1 , in that file there r 10 lines . my aim is to cut 2nd and 6th line of the file . what command we can use for this scenario. (8 Replies)
Discussion started by: natraj005
8 Replies

6. Shell Programming and Scripting

How to Delete Last Row from .csv file in perl

Hi , I've a perl script to convert .xls to .csv .After conversion I want to delete first 28 and the last row from .csv file.Is there any efficent way to achive this both together. I'm deleting first 28 rows by using folllowing my perl code: exec " tail -n+28 infile.csv > outfile.csv ... (7 Replies)
Discussion started by: ajaypatil_am
7 Replies

7. Shell Programming and Scripting

Delete first row last column

Hi All, I am having following file and I want to delete 1 row last column. Current File Content: ================ procedure test421 put_line procedure test321 test421 procedure test521 test321 procedure test621 test521 Expected File Content: =========================== procedure... (3 Replies)
Discussion started by: susau_79
3 Replies

8. UNIX for Dummies Questions & Answers

Delete first row of csv file

I have a csv file, which is > 2 Gigs. I need to BCP that file to Sybase db , but I cant upload that b'caz first row of the file is failing. ( having some errors probably.) I can manually insert the first line into db & then I can upload the rest of the data in file, if i can delete the first row. ... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

9. Shell Programming and Scripting

sed command to delete row

I want to use sed command to delete a matched row with a pattern. And I also want to delete previous and next row of that row. Which option can I use with sed ? (9 Replies)
Discussion started by: anhtt
9 Replies

10. Shell Programming and Scripting

How to delete a row in a file?

Does anyone know a way to delete rows 6-9 from the below output? I have searched the forum but did not find any thing helpful. backups01laxint.liuc(s){jsandova}<0>$ nsrjb -v | awk -F' ' '$3>=01{print $0}' | cut -b 1-79 | cat -n setting verbosity level to `1' 1 slot volume ... (17 Replies)
Discussion started by: jsandova
17 Replies
Login or Register to Ask a Question