Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Script to Read the last line of a file

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
jpexperts
Asked:
jpexperts
  • 3
1 Solution
 
ecwCommented:

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
 
ecwCommented:

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
 
jpexpertsAuthor Commented:
Awsome, Thanks a lot,  Do you know any sites that might be able to teach me how to write shell scripts.
0
 
ecwCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now