I want to follow the word BLOCK in ufw.log file every two seconds
I try this command:
sudo watch BLOCK /var/log/ufw.log
but I getting: sh: 1: BLOCK: not found
what is the right command?
Thank You
Edit
Following this command tail -f /var/log/ufw.log | grep BLOCK This is the output:
[ 6951.750905] [UFW BLOCK] IN=eth0 OUT= MAC=xxxx SRC=88.99.100.01 DST=180.20.40.11 LEN=48 TOS=0x00 PREC=0x00 TTL=110 ID=26663 DF PROTO=TCP SPT=59501 DPT=21 WINDOW=8192 RES=0x00 SYN URGP=0
How to filter the output to show only the SRC=«ip_address»
So that the output will be only: SRC=88.99.100.01
watch
command to do there, because a quick look at the manpage suggests it does something entirely different than what you're probably expecting. – Shadur-don't-feed-the-AI Jul 23 '16 at 17:48tail -f /var/log/ufw.log | grep BLOCK
– Shadur-don't-feed-the-AI Jul 23 '16 at 18:00--line-buffered
togrep
to suppress output buffering – iruvar Jul 23 '16 at 18:13tail -f …
is better, but what you were trying to do wassudo watch grep BLOCK /var/log/ufw.log
. You missed out the command,watch
takes a command. – ctrl-alt-delor Jul 23 '16 at 21:56tail -F /var/log/ufw.log | sed -n -e '/BLOCK/ {s/.*\(SRC=[^ ]*\).*/\1/p}'
. Using-F
instead of-f
tellstail
to not only follow the log, but to re-open the tailed filename if it gets rotated (i.e. closed, renamed, and replaced). – cas Jul 24 '16 at 12:53