Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find latest file

Status
Not open for further replies.

Tim2525

Technical User
Feb 7, 2005
51
US
Hi All,

Excuse my simple qs. I am VERY new to scripting and writing a script that would find the latest file (time) created in this format "db2_backup_08/31/05_14:39". I would need to find the file and once found, parse out the date time. Can someone give me suggestions on the best way of doing this?

TIA,
Tim
 
Something like:
ls -lt db2_backup* | head -1 | tr -s ' ' ' ' | cut -f9 -d ' '

Then do a similar cut for the date/time portion.



 
if all the files are in one directory and the filename and creationtime are the same: use 'ls -lt' or 'ls -ltr' to sort files. If you need to sort the files by name you could use 'sort' command with -k options. Please check the 'man sort'

Best Regards, Franz
--
Solaris System Manager from Munich, Germany
I used to work for Sun Microsystems Support (EMEA) for 5 years in the domain of the OS, Backup and Storage
 
Thanks all for the replies. That did it...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top