I'm trying to get a variable from /var/log/messages when the string "Attached" appears in /var/log/messages.
I've got so far, and stuck:
sudo stdbuf -o0 tail -f -n0 /var/log/messages | awk '{if ($9 == "Attached") print$8}'
This gives the usb device dev id eg [sdc] when a USB device is plugged in. FRom here I plan to mount the device as exfat. I'm using Centos 7, which does not automount exfat. fuse-exfat and exfat-utils are installed.
You are using 'tail -f' which will never terminate (it will wait for additional log messages). You probably want to 'grep' from the file, and pick the first (or last)
The 'exit' can be used to pick the first match.