nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell script tp Log files last line

This is a discussion on Shell script tp Log files last line within the Shell scripting forums, part of the Development/Scripting category; i need a shell script, that checks a line in ftp logs (contineous checking like tail -f) and after checking ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 28-02-2009, 03:30 PM
kasimani's Avatar
Senior Member
User
 
Join Date: Jul 2006
Location: India, Delhi
OS: CentOS, RedHat, Fedora, Ubuntu
Posts: 151
Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 4
kasimani is on a distinguished road
Send a message via Yahoo to kasimani
Exclamation Shell script tp Log files last line

i need a shell script, that checks a line in ftp logs (contineous checking like tail -f) and after checking it should echo the latest last line.


ex.
if the last entry in log is:

/file.xml b _ i r cricarc ftp 0 * c

then it should save output to a file.


Pl. help me out of this problem

Last edited by kasimani; 28-02-2009 at 03:55 PM.
Reply With Quote
  #2 (permalink)  
Old 28-02-2009, 09:25 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Use something as follows:
Code:
tail -1 /var/log/file.name > output.txt
To append latest entry
Code:
tail -1 /var/log/file.name >> output.txt
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 04-03-2009, 09:58 AM
kasimani's Avatar
Senior Member
User
 
Join Date: Jul 2006
Location: India, Delhi
OS: CentOS, RedHat, Fedora, Ubuntu
Posts: 151
Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 4
kasimani is on a distinguished road
Send a message via Yahoo to kasimani
Default

dear, i know this, what if i want the this result in continuous manner like using "tail -f"
Reply With Quote
  #4 (permalink)  
Old 24-03-2009, 03:25 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
spabba is on a distinguished road
Default

tail -f log file >> test1 &

after you break the continous loop you can use...

tail -1 test1

does this help ?
Reply With Quote
Reply

Tags
linux , log files , tail , unix


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Shell script download mp3 files in bulk from a site vivekv Shell scripting 6 17-04-2009 11:33 PM
HPUX Unix comparing 2 large files line by line raj HP-UX 1 11-02-2008 05:20 PM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 08-02-2007 03:45 PM
shell script to open log files and check for faults trueman82 Shell scripting 1 23-11-2006 02:35 AM
shell script that parses multiple log files and checks for a Anonymous Shell scripting 1 15-11-2006 09:38 PM


All times are GMT +5.5. The time now is 03:30 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38