LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2010, 11:36 AM   #1
djsez123
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
Smile 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
 
Old 01-26-2010, 11:41 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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
 
Old 01-26-2010, 11:50 AM   #3
djsez123
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
Old 01-26-2010, 12:01 PM   #4
phlyer
Member
 
Registered: Jan 2010
Distribution: CentOS, Vector Linux, Scientific Linux, Rocks
Posts: 36

Rep: Reputation: 17
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
for more details, please see "man tail"

Hope that helps
M
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Newbie Question soulxcavtor Linux - Newbie 2 05-24-2006 01:06 PM
Very Easy Quick Question From an Newbie. Anthony1uk Linux - Newbie 2 06-08-2005 12:34 PM
Quick Question (even a Linux Newbie can help me!) perry Mandriva 5 07-21-2004 11:17 AM
Quick newbie question about pico phil1076 Linux - Newbie 3 12-04-2001 02:35 PM


All times are GMT -5. The time now is 09:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration