The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find and store files based on FileName and Modified Time edisonantus UNIX for Advanced & Expert Users 2 02-19-2008 11:25 AM
find files modified in a specific month omer_ome UNIX for Advanced & Expert Users 1 07-02-2006 06:43 AM
find files modified in a specific month omer_ome SUN Solaris 1 07-02-2006 06:38 AM
find files modified in a specific month omer_ome HP-UX 1 07-02-2006 06:36 AM
shell script to find files naren_samba2005 Shell Programming and Scripting 2 10-21-2005 02:06 AM

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

Join Date: Jan 2008
Location: Bangalore
Posts: 17
Unhappy Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!

hi all,

I need to find out the last 2 modified files in a folder.There is some way by which,we can check the timestamp and find out..??please help this is urgent.

Thanks in Advance

Anju
Reply With Quote
Forum Sponsor
  #2  
Old 01-31-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
As simple as

Code:
ls -Atr | tail -2
Reply With Quote
  #3  
Old 01-31-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
Thumbs up

Dear Anju,

to get the timestamp of a file, try this,

ls -l filename|awk '{print $6$7$8}'

then the result will be in the format of MonDDYY
here in the place of YY u'll get the time of the file creation if the file get created within 6 months. if the file got created before 6 months then in the place of YY value will be the year(2007 etc)

Regards,
Pankaj
Reply With Quote
  #4  
Old 01-31-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
Thumbs up

try this also

ls -lt |head -2

Regards,
Pankaj
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:56 AM.


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