![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| generated CSV file on AIX | mpang_ | Shell Programming and Scripting | 0 | 09-05-2006 08:01 PM |
| Need a script to Append date to generated .txt file | prince_of_focus | Shell Programming and Scripting | 2 | 08-01-2006 11:51 AM |
| How to FTP a file generated at UNIX Box to NT Box | Ruchir | UNIX for Advanced & Expert Users | 2 | 08-11-2005 02:55 AM |
| Automatically Rename Last Generated File | pieter023 | Shell Programming and Scripting | 2 | 05-25-2005 11:14 AM |
| Core File Not Being Generated in AIX | S.P.Prasad | High Level Programming | 6 | 09-23-2003 02:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
get the last generated log file
Hi
I need to get the last generated file in a directory using ls -ltr. I need to store the output of ls -ltr in a variable. it will like this $xyz = -rw-rw-r-- 1 sblp003 siebel 1060 Dec 18 13:33 from this output, I need to do a substring to get this value alone "Dec 18 13:33". Can you guys please help me write a shell script to implement this logic. I am not too familiar with shell scripting. Thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
xyz=$(ls -ltr | grep ^- | tail -1 | awk ' { print $6,$7,$8 } ')
|
|
#3
|
|||
|
|||
|
anbu
thanks for the reply. small modification to myy above requirement. I need to do ls -ltr for files starting with this 'eCustomerCME*'. Pls help me do this. thanks a lot!! |
|
#4
|
|||
|
|||
|
Try this, just change yoru "-" to "eCustomerCME" and take away the tail and awk
Code:
xyz=$(ls -ltr | grep ^eCustomerCME*) |
|
#5
|
|||
|
|||
|
i tried that, but is returning a blank result.. any other suggestions plz!
|
|
#6
|
|||
|
|||
|
anbu
ur code is working exactly as i expected. thanks! just a small modification, it has to do a ls -ltr only for files starting with 'eCustomerCME'. I would basicall search for eCustomerCME*. thanks |
|
#7
|
|||
|
|||
|
xyz=$(ls -ltr eCustomerCME* | grep ^- | tail -1 | awk ' { print $6,$7,$8 } ')
|
|||
| Google The UNIX and Linux Forums |