LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-26-2017, 07:37 PM   #1
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 633

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
Using cut in continuous follow (tail -F)


I want to follow a file, filter for the word FOOBAR and only display certain fields of it by delimiting with a space.
Is this possible?

This works ok, but I just want the 1st, 2nd and 5th field
Code:
sudo tail -F /var/log/syslog | grep --color FOOBAR
This just sits there with no output.
Code:
sudo tail -F /var/log/syslog | grep --color FOOBAR | cut -d' ' -f 1,2,5
Running this works as expected (example output would be Oct 2 127.0.0.1)
Code:
sudo tail /var/log/syslog | grep --color FOOBAR | cut -d' ' -f 1,2,5

Last edited by Sefyir; 10-26-2017 at 11:02 PM.
 
Old 10-26-2017, 08:18 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Try using the "--line-buffered" option of grep: https://www.gnu.org/software/grep/ma...#Other-Options
 
1 members found this post helpful.
Old 10-26-2017, 11:01 PM   #3
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 633

Original Poster
Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
That solved it. Thanks

Code:
       --line-buffered
              Use line buffering on output.  This can cause a performance penalty.
Code:
sudo tail -f /var/log/syslog | grep --line-buffered --color FOOBAR | cut -d' ' -f 1,2,3,7,11
 
  


Reply

Tags
cut, tail


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursively tail follow all files in a directory, all subdirectories, and so on... dragonmaximadriver Linux - General 8 01-14-2015 08:43 AM
[SOLVED] trouble piping tail -f, grep and cut. disciple218 Linux - Software 7 11-12-2013 06:35 AM
help with cut command using find. Cut last 8 characters leaving the rest ncsuapex Programming 4 09-16-2009 08:55 PM
How to use command grep,cut,awk to cut a data from a file? hocheetiong Linux - Newbie 7 09-11-2008 07:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration