?
Solved

Script to Read the last line of a file

Posted on 2003-03-19
4
Medium Priority
?
220 Views
Last Modified: 2010-04-17
I need to create a script that will read the last line of a file and if it contains the word BUSY then send out an email.
Thanks in advanced for your help.
0
Comment
Question by:jpexperts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 5

Expert Comment

by:ecw
ID: 8169733

Unix...

#!/bin/sh

PATH=/bin:/usr/bin ; export PATH

if tail -1 file | grep BUSY > /dev/null ; then
  mailx -s "Last line contains BUSY" someone@somwhere <<EOF
The last line of your file was BUSY!

EOF
fi
0
 
LVL 5

Accepted Solution

by:
ecw earned 100 total points
ID: 8169735

Unix...

#!/bin/sh

PATH=/bin:/usr/bin ; export PATH

if tail -1 file | grep BUSY > /dev/null ; then
  mailx -s "Last line contains BUSY" someone@somwhere <<EOF
The last line of your file was BUSY!

EOF
fi
0
 

Author Comment

by:jpexperts
ID: 8181511
Awsome, Thanks a lot,  Do you know any sites that might be able to teach me how to write shell scripts.
0
 
LVL 5

Expert Comment

by:ecw
ID: 8181772
Off the top of my head no, but most of it is knowing what commands are available, what they do, and how to use them.  For this I suggest going through the manpages and checking the synopsis lines.  read anything that get's your interest.

I've found a couple of things via yahoo,
 http://www.shelldorado.com/links/index.html#tutorials
has a lot of links tha may be useful, as does
 http://www.bolthole.com/solaris/ksh.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question