| | |
print only the last entry of the file
![]() |
•
•
Join Date: Nov 2007
Posts: 45
Reputation:
Solved Threads: 0
i wanted to printout the last entry of the file without passing in any arguments but how can i able to do it? i know how to print out where argument is supplied and doing a grep to match it.
example inside the file i have:
apple:2:1:3
orange:1:2:3
grape:2:3:4
i wanted only to print out(last entry of my file):
grape:2:3:4
example inside the file i have:
apple:2:1:3
orange:1:2:3
grape:2:3:4
i wanted only to print out(last entry of my file):
grape:2:3:4
Shell Scripting Syntax (Toggle Plain Text)
sed -n '$p' filename
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
True. I like to give somewhat obscure answers to things that I belive are probably/possibly homework questions. That way, if they are not a homework question, the OP has something (s)he can use, and if they are, the teacher knows, as soon as (s)he sees it, that the student probably did not come up with it themselves. ;-)
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Apr 2006
Posts: 148
Reputation:
Solved Threads: 40
sed will be slower than tail for huge files. Just a tip
![]() |
Similar Threads
- read-delete lines from a text file (PHP)
- Tips in File I/O in Dev C++ (C)
- Reading an input file as a class memeber function (C++)
- Write to a file (C)
- noobie asking for assistance with file parsing... (Perl)
- Highjack file Ie wont download (Viruses, Spyware and other Nasties)
- header file/ classes (C++)
- Distance between 2 points (C++)
- The White screen for analyzing log file (Viruses, Spyware and other Nasties)
Other Threads in the Shell Scripting Forum
- Previous Thread: .sh to vbs
- Next Thread: check input arguments is upper or lower case
| Thread Tools | Search this Thread |






