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

sed -n '$p' filename
commented: I'll have to look into this - don't quite understand how it works. Nice! +1

thanks masijade! thanks for ur help!!!

Or
tail -1 file

^ Nice and simple, just the way I like it... though I'm more interested in the sed example.

Or
tail -1 file

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. ;-)

sed will be slower than tail for huge files. Just a tip

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.