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 07-29-2014, 04: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, 06:32 PM   #2
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 364

Rep: Reputation: 158Reputation: 158
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


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

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

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