The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Enterprise Unix Roundup: The Ghost of Unix Future - Server Watch iBot UNIX and Linux RSS News 0 12-19-2007 09:20 AM
Running UNIX commands remotely in Windows box from Unix box – avoid entering password D.kalpana UNIX for Dummies Questions & Answers 1 04-20-2007 02:24 AM
FTP script for sending a file from one unix directory to another unix server director raja_1234 Shell Programming and Scripting 1 11-30-2006 04:57 AM
Unix Sco Open Server, Windows Computers Problem Access Unix Shared Files Help!!!!! haggo Filesystems, Disks and Memory 2 08-23-2006 08:39 AM
Unix History Question: Why are filenames/dirnames case sentsitive in Unix? deckard UNIX for Dummies Questions & Answers 3 03-26-2005 10:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
about unix

i want to get the latest file from the directory ...

then extract the specific lines from it(the latest file which i extracted) starting from the charcters ...INSTANCEID ...Program started at.... program ended at ....

i want to do it for the multiple dirctories at the same time

could anyone give me the script for this
Reply With Quote
Forum Sponsor
  #2  
Old 07-25-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 983
Cool here is a start

You really did not provide much detail - examples of input and desired output. However, the following should get you started. See what you can write of a script, and post back follow-up questions.

Either of the following will give you the latest (most recent file). There are many ways to find this out, by the way.
Code:
> ls -lt | grep "^-" | head -1 | awk {'print $9'}
comp.log
> ls -lt | grep "^-" | head -1 | tr -s " " | cut -d" " -f9
comp.log
you can set a variable for the results, with
Code:
file1=$(ls -lt | grep "^-" | head -1 | awk {'print $9'})
A script can then cat or head or grep on $file1
I would suggest trying to do this for one file. Once you can do that, it is farily easy to insert the command(s) into a loop function.
Reply With Quote
  #3  
Old 07-30-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Cool thank u

Hello there

thanu for ur reply.....but i m not getting the desired output

ill explain u in detail.....wht we do

we first use the command ls -lt /apps/psoft............../FNTEDP01*

through which we get the no of files in the directory of the format

/apps..................../FNTEDP01_1423165.LOG

from this we pick the latest file as per the date

and then use more command to get the information and then the tail command if we dont get the entire information from the more

(we dont use the cat command bec some of the files may be very large )

then pick the information from the file

we do this for several files ....
Reply With Quote
  #4  
Old 07-30-2008
Registered User
 

Join Date: Jul 2008
Posts: 51
Hi ,

Kindly check whether the below script is working or not.

file = `ls -lt | grep "^-" | head -1 | awk { print $9 }`
cat file | grep "^FNTEDP01" > file1
for i in `cat file1`
do
more $i
done

Thanks and Regards,
JeganR
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0