[ACCEPTED]-How do you pipe input through grep to another utility?-cut
Accepted answer
Assuming GNU grep, add --line-buffered
to your command 5 line, eg.
tail -f logfile | grep --line-buffered org.springframework | cut -c 25-
Edit:
I see grep buffering isn't the 4 only problem here, as cut doesn't allow 3 linewise buffering.
you might want to try 2 replacing it with something you can control, such 1 as sed:
tail -f logfile | sed -u -n -e '/org\.springframework/ s/\(.\{0,25\}\).*$/\1/p'
or awk
tail -f logfile | awk '/org\.springframework/ {print substr($0, 0, 25);fflush("")}'
On my system, about 8K was buffered before 2 I got any output. This sequence worked to 1 follow the file immediately:
tail -f logfile | while read line ; do echo "$line"| grep 'org.springframework'|cut -c 25- ; done
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.