Leaving last 30 lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Leaving last 30 lines
# 8  
Old 01-10-2013
Code:
tail -r temp | nawk 'NR>30'|tail -r

This is three commands, nearly a script Smilie
# 9  
Old 01-10-2013
But jotne we can execute it in one go
correct..
Code:
tail -r temp | nawk 'NR>30'|tail -r

But I didnt try yet is it working or not. I am not sure what
Code:
tail -r

does
# 10  
Old 01-10-2013
try also:
Code:
tail -30 file

# 11  
Old 01-10-2013
If you don't know what tail -r does, or any other command, read the manual page for it.

Code:
man tail

Quote:
Originally Posted by rdrtx1
try also:
Code:
tail -30 file

That will display the lines the user doesn't want.
# 12  
Old 01-10-2013
scott and rdrtx1, I want to leave last 30 line, so
Code:
tail -30 filename

is not helpful
# 13  
Old 01-10-2013
try also:
Code:
tail -30 filename > f.tmp
mv f.tmp filename

# 14  
Old 01-10-2013
Code:
sed -n "1,$(( `wc -l < filename` - 30 ))p" filename

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to delete identical lines while leaving one undeleted?

Hi, I have a file as follows. file1 Hello Hi His Hi Hi Hungry hi so I want to delete identical lines while leaving one of them undeleted. So desired output will be Hello Hi (2 Replies)
Discussion started by: beginner_99
2 Replies

2. Shell Programming and Scripting

Leaving directory Error

Hi, i have a question, when I install any software it give error message like as follow : sudo make password for csm: make all-recursive make: Entering directory `/home/csm/Desktop/miRanda-3.3a' Making all in man make: Entering directory `/home/csm/Desktop/miRanda-3.3a/man' make:... (18 Replies)
Discussion started by: harpreetmanku04
18 Replies

3. Shell Programming and Scripting

Leaving space inside sed

Hi Gurus, I have 2 files File1 : veg apple ap pl le end veg orange or an ge end File2: (2 Replies)
Discussion started by: jayadanabalan
2 Replies

4. Red Hat

How to compare file leaving certain filelds?

How to compare two files leaving certain fields, using diff command the entire file is being compared. Can any one please help. (5 Replies)
Discussion started by: ramsavi
5 Replies

5. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

6. Shell Programming and Scripting

Leaving for loop on condition

hi all, i have a problem...no dream :-) i want to scan a file i use the loop famous while read line do do < myfile but this scan must finish when find the another string . How can i do it? best regards for all. Francesco Please use descriptive subjects. "script." doesn't tell... (5 Replies)
Discussion started by: FrancescoIt
5 Replies

7. UNIX for Dummies Questions & Answers

Delete all rows but leaving first and last ones

Hello, Merry Christmas to all! I wish you the best for these holidays and the best for the next year 2011. I'd like your help please, I need to delete all the rows in the third column of my file, but without touching nor changing the first and last value position, this is an example of my... (2 Replies)
Discussion started by: Gery
2 Replies

8. Shell Programming and Scripting

Remove lines of the same time stamp leaving the highest

Hi guys, I have a log that looks like that below. Columns 2 3 4 5 6 7 is the date/time stamp separated by comma. UUU,02,06,2010,10,00,00,00,0000000000000000,0000000000000000,0000000000001224 UUU,02,06,2010,10,05,00,00,0000000000000000,0000000000000000,0000000000001502... (2 Replies)
Discussion started by: borderblaster
2 Replies

9. Solaris

leaving ALOM mode

Some netra 240 machines went into ALOM mode, and when I issue the command; sc> console it got stuck, does it mean Solaris OS had crashed ? or what can I do to reboot,because reboot is not starting? And advice ? (3 Replies)
Discussion started by: xramm
3 Replies
Login or Register to Ask a Question