LinuxQuestions.org
Review your favorite Linux distribution.
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 05-31-2015, 01:15 PM   #1
Buhemba
LQ Newbie
 
Registered: May 2015
Posts: 1

Rep: Reputation: Disabled
File searching in log


Hi team,
Am a newbie in Linux, have a runing application using tail -f to see the ongoing logs, am having a challenge i want to see a specific file seen yesterday but its seems i can reach the line of the log but not the contents of the logs kindly help me out.

Thanks
 
Old 05-31-2015, 01:32 PM   #2
runlevl4
LQ Newbie
 
Registered: May 2015
Posts: 5

Rep: Reputation: Disabled
I don't quite understand what you mean. You can't see the log contents? What happens? Can you be a little more clear?
 
Old 06-01-2015, 10:39 AM   #3
mikenash
Member
 
Registered: Dec 2014
Posts: 76

Rep: Reputation: Disabled
File searching in log

Tail will show only the last part of a file. You should issue; man tail, for more information. You can cat a file to list the entire contents; i.e. cat somefile.txt. You should issue; man cat, for more information. To reduce out put you can use grep to display selected information; i.e. cat somefile.txt | grep today. This will display lines with the word today in it.
 
Old 06-24-2015, 01:09 PM   #4
ltwilliams58
LQ Newbie
 
Registered: Jun 2015
Distribution: Mint Ubuntu
Posts: 27

Rep: Reputation: 3
As Mike said, tail shows the tail of the file, -f makes it update when the file updates. To see the entire file, cat will spit it out, grep can spit out lines that match a search criteria. The one I prefer is less (a more clone). It lets be walk the file in both directions and search for content. Unlike grep, it will let be view the search results in context.

A GUI solution I've used is glogg, it will tail a file but also highlight search results
 
Old 06-24-2015, 02:02 PM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,170
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
Code:
tail -f -n 50 /path/to/file
will display 50 lines while tailing -f on a file.
For some other file, you should grep for interesting strings.

eg: Don't use tail -f with any option on a file that isn't being currently written.
If it's archived, or rotated, use [z]grep <string> /path/to/file
 
  


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
Searching for a Productivity Tool - Window Focus Log Zizoo Linux - Software 2 12-06-2011 03:22 AM
Searching var/log/updates.log using grep noobee26 Linux - Newbie 15 06-27-2011 02:42 PM
log file tricks - searching / digging rajeshkahara Linux - Server 2 08-22-2009 05:32 PM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 05:14 PM
searching log files in linux ramanika Linux - Newbie 2 10-21-2008 12:56 PM


All times are GMT -5. The time now is 04:02 PM.

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