LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-06-2014, 11:31 AM   #1
lqstin
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Rep: Reputation: Disabled
Add empty lines between tail output


Hi,

I'm using tail -f file.txt to watch an application's progress. What I want to do is to add an empty line between each outputted line (or replace \n with \n\n). So for

line1
line2


I want to see

line1

line2


Any ideas?

Thanks,
 
Old 02-06-2014, 11:40 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Code:
tail -f file.txt | awk {'print;print "\n"'}
 
1 members found this post helpful.
Old 02-06-2014, 11:44 AM   #3
lqstin
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks... Works Great!
 
Old 02-06-2014, 12:40 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Another one:
Code:
tail -f file | sed G
 
1 members found this post helpful.
Old 02-07-2014, 05:43 AM   #5
lqstin
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Smile

Thanks Guys,

Both Work Great.. but now I'm greedy and want to do some fancy stuff .. how can I add some color highlighting?

So what I want for output is:

blah blah highlight blah blah
<empty line>
blah blah highlight blah blah


grep --color seems to remove the added empty lines..

Thanks Again,
 
Old 02-07-2014, 06:09 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
On my CentOS box I just tried the following:

Code:
grep --colour=always "ten-tenths" /var/log/maillog | awk {'print;print "\n"'}

grep --colour=always "ten-tenths" /var/log/maillog | sed G

tail -f /var/log/maillog | grep --colour=always "ten-tenths" | sed G
and got colour and empty lines, so not sure what's happening with yours.
 
1 members found this post helpful.
Old 02-07-2014, 06:17 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
looks like:
Code:
less -p <pattern> -f file1.txt
works (will highlight pattern), but pipe (into awk and/or sed) removes that again, so:
Code:
tail -f /var/log/maillog | sed G | less -p <pattern>
may work, but not really sure this is what you need
 
Old 02-07-2014, 06:21 AM   #8
lqstin
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks @TenTenths

I was using --color w/o always.

Now the following works:

tail -f file.txt | grep --color=always DEBUG | sed G

Though it seems to buffer a bit, so the lines are not shown immediately..

Thanks again..

Last edited by lqstin; 02-07-2014 at 06:22 AM.
 
  


Reply


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
[SOLVED] Empty lines in output of tcpdump hua Linux - Networking 2 05-23-2012 02:00 AM
tail the output of tail -n 1 raj k yadav Linux - Newbie 5 02-07-2010 12:26 AM
netstat - grep - tail -f output log manwithaplan Linux - Networking 4 08-21-2009 06:36 PM
fdisk and tail result in no output ubume2 Ubuntu 1 05-07-2008 05:47 AM
can output of tail be redirected? dsids Linux - Newbie 19 10-16-2006 03:19 AM


All times are GMT -5. The time now is 03:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration