SED Command
Can someone please tell me a way to display the last 3 lines of a file using the sed command?
Thanks in advance. |
It might be a lot easier for you to understand tail
Code:
tail -n3 file.txt Code:
sed -e :a -e '$q;N;4,$D;ba' file.txt |
You're a jewel, homey, but you just did the guys homework for him. OTOH, I'd like to be there to hear his explanation when the instructor asks him just how that works. lol.
|
I think that most questions are asking someone else to do the homework ( googling ) for them. At any rate, it seems alot of people would be happier if I didn't post at all.
It may be easier for a person to explain the use of tac which is cat from the bottom of the file... Code:
tac < file.txt | sed -n '1,3p' | tac |
Quote:
My personal rule is to help if it looks like the individual has made an effort. Note that many will tell you that we are not supposed to help with homework---not true. The forum rules only say that the requester should not EXPECT it. |
All times are GMT -5. The time now is 08:29 AM. |