•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 427,787 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,825 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 585 | Replies: 6
![]() |
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Rep Power: 1
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
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
Or
tail -1 file
tail -1 file
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
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: 140
Reputation:
Rep Power: 3
Solved Threads: 26
sed will be slower than tail for huge files. Just a tip
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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



Linear Mode