LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-29-2014, 03:43 PM   #1
rkal
LQ Newbie
 
Registered: Jul 2014
Posts: 1

Rep: Reputation: Disabled
Append Hostname to tail -F


Hello Everyone,

I'm trying to append the host name and the file name to every line of tail -f output.

Used tail -v to retrieve the file name , is there anyway to append the host name as well ?

Thanks
 
Old 07-29-2014, 05:32 PM   #2
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Not sure if this is exactly what you asked for, but it might be a step in the right direction. You can use the find command to select the files to be tailed (in my example, *.txt), and use multiple -exec statements to get the desired output:
Code:
find . -maxdepth 1 -name '*.txt' -exec echo -e "\n" host=$(uname -n) file={} \; -exec tail {} \;
 
  


Reply



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
HOSTNAME = hostname -> HOSTNAME: command not found ? thomas2004ch Linux - Software 2 08-26-2013 08:25 PM
tail the output of tail -n 1 raj k yadav Linux - Newbie 5 02-06-2010 11:26 PM
Changed hostname during install, now CUPS has wrong hostname on web interface slinx Linux - Software 1 08-07-2009 08:01 PM
How to make newer "tail" behave like older "tail" rylan76 Linux - Software 4 12-07-2007 04:27 AM
How to append hostname in a script anjaan Programming 5 06-14-2004 10:41 AM

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

All times are GMT -5. The time now is 03:36 AM.

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