display all lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting display all lines
# 1  
Old 02-17-2007
display all lines

Dear Experts,

can any one tell me how to display all lines except the last line of a file using awk.
take care
Regards,
SHARY
# 2  
Old 02-17-2007
try this:
Code:
awk '{

if (NR != $) 
{

print $0
}

}' filename

or 

awk 'NR != $  { print $0 }' filename

Try this and do let me know the output.

Last edited by ahmedwaseem2000; 02-17-2007 at 09:58 PM..
# 3  
Old 02-17-2007
Code:
 sed '$d' file

# 4  
Old 02-17-2007
Code:
awk '{if(NR>1)print x;x=$0}' infile

With ed you can modify your original file right away:

!!! Be careful, this command will modify your original file !!!

Code:
ed infile <<'EOF'
d
w
q
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display lines between timestamp

Hi Gurus, I have a software which logs event in the log file and it has become to big to search into it. I want to display all the lines from the log files between <Jul 21, 2016 3:30:37 PM BST> to <Jul 21, 2016 3:45:37 PM BST> that is 15 min data . Please help Use code tags, thanks. (10 Replies)
Discussion started by: guddu_12
10 Replies

2. Shell Programming and Scripting

To display 10 lines before and after the error

Hi, I have a huge log file and I wanted to check for the errors which happened on the particular time frame- Since its huge - vi is making difficult for me So I used the below command to grep -i 'ERROR' wls.log | grep 'Apr 8' which showed there were few errors Is there some way, we... (5 Replies)
Discussion started by: ajothi
5 Replies

3. Shell Programming and Scripting

Display all lines after and before two different strings

Hi, What is the easiest way to display set of lines after a search string (x) and before search (y) . The grep -A -B doesn't seem to be helpful in this case. Any ideas.. -Kevin (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

4. UNIX for Dummies Questions & Answers

How to display lines by range specified?

My input file is N3*123 ABC FLATS~ REF*D9*10000000001~ N3*223 ABC FLATS~ REF*D9*10000000002~ N3*323 ABC FLATS~ REF*D9*10000000003~ N3*423 ABC FLATS~ REF*D9*10000000004~ N3*523 ABC FLATS~ REF*D9*10000000005~ N3*623 ABC FLATS~ REF*D9*10000000006~ N3*723 ABC FLATS~ REF*D9*10000000007~ N3*823... (2 Replies)
Discussion started by: nsuresh316
2 Replies

5. UNIX for Dummies Questions & Answers

Display last few lines

I have huge text files and I only want to display on the screen the last lines. with less -G file.txt i get the beginning of the file. (2 Replies)
Discussion started by: FelipeAd
2 Replies

6. UNIX for Dummies Questions & Answers

Display lines not starts with #

hiiiii $ grep ^"#" $file Will give the lines , which starts with # .And I wanna get the lines which are not starting with #. How to implement that. Thanking you Krish:b: (10 Replies)
Discussion started by: krishnampkkm
10 Replies

7. Shell Programming and Scripting

display 5 lines from the particular text

Hi All, please help me to display 5 continious lines from a particular text. my file is as below. file1.txt ------ Good 1 2 3 4 5 luck 1 2 3 I want to diplay 5 lines from the word Good. (4 Replies)
Discussion started by: little_wonder
4 Replies

8. Solaris

grep and display few lines before and after

Hi is there a way in grep to display few lines before and after the pattern?? I tried options A and B and after-context and before-context. But they don't work on Solaris platform. please advise. (13 Replies)
Discussion started by: melanie_pfefer
13 Replies

9. Shell Programming and Scripting

Display file without # lines

Hi to all in this great forum, im sure this has been asked lots of times before but ive been looking for the past day and cant find the answer. I use cat/some/file to display its contents but how can i get it to not display hashed out lines, or do i need another command, Thanks in advance:) (5 Replies)
Discussion started by: dave123
5 Replies

10. Shell Programming and Scripting

display no of empty lines

I want to display the number of empty lines in a file. I guess i should use 'grep'...but how.. 10x for those who'll help. (5 Replies)
Discussion started by: atticus
5 Replies
Login or Register to Ask a Question