Reputation: 1074
I'm using tail -f for watching log files in "real time". What to do so be able to view only lines containig 127.0.0.1 for example ?
Upvotes: 1
Views: 243
Reputation: 77876
In case you want to grep all the lines containing any IP address and not only 127.0.0.1 then
tail -f filename|grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$'
Upvotes: 1
Reputation: 2149
Watch is also a cool command for this
watch grep '127.0.0.1' foo
and it will update every 2 seconds.
Upvotes: 2
Reputation: 104080
tail -f /path/to/log/file | grep --line-buffered 127.0.0.1
The --line-buffered
is not strictly needed for grep(1)
in this case, but it would be if you wanted to send output to less(1)
or some further processing steps, and still wanted to see individual lines as they were logged. (See setvbuf(3)
for full details on the buffering.)
Upvotes: 4