Quick Question of Newbie...
Hey Guys! Thanks for helping out. Here is what I need help with.
Assume that i've already navigated to the directory containing this file. What command(s) would you use to find the last time the phrase “Hosting” appears in a file? I need 2 different ways to accomplish this. Thanks!! Steve |
Hello and welcome to LinuxQuestions Steve,
Your question looks like homework to me and per the LQ rules there will not be a lot of users inclined to offer you a 'ready to go' answer. On the other hand if you've figured out something but are getting errors using a command or script, we'd be happy to point you in the right direction. That being said: Enjoy Linux! Kind regards, Eric |
Well, not really homework, but a question I was asked. I have one solution, which I have pasted below, but I can't figure out how to go about doing it a diffrent way.
grep -wn "Hosting" messages - This command will display all lines that have Hosting, and also include the line number None the less, thanks!! Steven |
assuming you are referring to the last occurrence of <pattern> on a line in <file>,
you could pipe your grep output into tail Try: Code:
grep <pattern> <file> | tail -n1 Hope that helps M |
All times are GMT -5. The time now is 10:07 PM. |