LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   File searching in log (https://www.linuxquestions.org/questions/linux-newbie-8/file-searching-in-log-4175544104/)

Buhemba 05-31-2015 12:15 PM

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

runlevl4 05-31-2015 12:32 PM

I don't quite understand what you mean. You can't see the log contents? What happens? Can you be a little more clear?

mikenash 06-01-2015 09:39 AM

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.

ltwilliams58 06-24-2015 12:09 PM

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

Habitual 06-24-2015 01:02 PM

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


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