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 |
I don't quite understand what you mean. You can't see the log contents? What happens? Can you be a little more clear?
|
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.
|
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 |
Code:
tail -f -n 50 /path/to/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. |