Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-10-2006, 06:34 AM   #16
Registered: Aug 2004
Distribution: Suse
Posts: 44

Rep: Reputation: 16
Emailing output of tail -f

How would I be able to do something like this:

tail -f log | grep "I'm finished" | mail -s "It Is Finished"

What I want is as soon as tail -f detects the string "I'm finished", to email the output of the "grepped" string (not the entire log) and return me to a command-prompt.

Is that doable?
Old 06-12-2006, 01:28 AM   #17
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
check out this thread
Old 06-12-2006, 04:46 AM   #18
spirit receiver
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
You could use process substitution:
#! /bin/bash

while read
	mail -s "New line in logfile" dude <<- EOF
	Hi Dude,
	a new line was appended to your logfile. Here it is:
done < <( tail -f logfile )
Note that this will spawn an extra process for the tail command, which will still be running if the script itself is finished.
Old 10-14-2006, 04:07 PM   #19
Registered: Sep 2004
Posts: 128

Rep: Reputation: 15
hi i'm trying to do a tail of the processes under my system. I can't seem to get it to work. I have tried doing tail this way

tail -f|ps aux

The processes display but it is static it's not updating the processes. I'm doing this just to understand the tail and Pipe commands, I might want to try redirecting the output to a text file too just for fun. Any thoughts guys? Thanks
Old 10-16-2006, 02:19 AM   #20
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
i'm trying to do a tail of the processes under my system.
What do you mean by this? Do you want to run tail on the output of some of your processes? Or do you want
tail to filter the output of your "ps" command, that gives you a list of processes?

Assuming you mean the latter:
ps -aux just lists some running processes once, not continuously, so you don't need tail's -f option.
Also, I think you have the order of the commands reversed:
ps -aux | tail
displays only the last few lines of ps's output. You can control how many lines you want by adding "-n" (replace n with the number you want) to "tail".

And finally, try to start a new thread when you have a question, rather than hijacking someone else's, which is against the forum policy.

Last edited by timmeke; 10-16-2006 at 02:20 AM.


bash, script, source

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
iptables - why am I still being redirected? michaelsanford Linux - Networking 1 05-23-2005 03:52 PM
GPG and redirected input Vookimedlo Linux - Software 1 04-30-2005 04:32 PM
Is a Domain being redirected? rigel_kent Programming 0 02-14-2005 06:43 AM
my domain is getting redirected to a different ip. QS_Shorty Linux - Newbie 3 02-10-2004 08:22 PM
Some windows redirected to console (not in VNC) jswilson Red Hat 6 10-31-2003 03:22 PM

All times are GMT -5. The time now is 12:44 PM.

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