LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Append Hostname to tail -F (https://www.linuxquestions.org/questions/linux-newbie-8/append-hostname-to-tail-f-4175512654/)

rkal 07-29-2014 03:43 PM

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

Beryllos 07-29-2014 05:32 PM

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 {} \;


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