![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
Code:
file1=$(ls -lt | grep "^-" | head -1 | awk {'print $9'})
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. |
|
#3
|
|||
|
|||
|
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 .... |
|
#4
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |