The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find the latest file on Unix or Linux duke0001 UNIX for Dummies Questions & Answers 10 4 Weeks Ago 01:31 AM
Shell script to ftp latest file im_new Shell Programming and Scripting 7 11-22-2007 10:15 PM
finding latest file having timestamp on it..... kaushik25 Shell Programming and Scripting 1 08-06-2007 07:35 PM
How to find whenther given value is in betwwen min and Max in unix shell scripting pinky UNIX for Dummies Questions & Answers 5 07-27-2007 07:52 AM
Find and remove all but the latest file hyennah Shell Programming and Scripting 4 03-28-2007 08:09 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-06-2007
Registered User
 

Join Date: Aug 2007
Posts: 2
Post Unix shell scripting to find latest file having timestamp embedded...

Hi guys,

I have a directory in UNIX having files with the below format, i need to pickup the latest file having recent timestamp embedded on it, then need to rename it to a standard file name.

Below is the file format:

filename_yyyymmdd.csv, i need to pick the latest and move it with the standard file name.

Please help.

regards,

sundar
Reply With Quote
Forum Sponsor
  #2  
Old 08-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
One way:
Code:
now=`date +%Y%m`
ls -rt filename_"$now"*.csv | tail | read file
cp $file standard_file_name
This looks for the last file made this month. Assuming the filename does reflect the last time the file was written to.
Reply With Quote
  #3  
Old 08-06-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Please, do not duplicate posts:
http://www.unix.com/shell-programmin...amp-on-it.html
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 06:59 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