The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Finding the oldest file janet Shell Programming and Scripting 5 03-23-2009 10:31 AM
Find Oldest file in a directory tree rahulrathod Shell Programming and Scripting 25 01-12-2009 12:45 PM
how to grep the oldest file in a directory ericaworld Shell Programming and Scripting 1 05-29-2007 01:24 PM
Removing the oldest file in a directory pavan_movva Shell Programming and Scripting 2 10-10-2006 11:38 AM
Oldest File In A Directory bergerj3 UNIX for Dummies Questions & Answers 2 02-27-2002 03:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-07-2006
pavan_movva pavan_movva is offline
Registered User
  
 

Join Date: Oct 2006
Location: India
Posts: 4
Finding the oldest file in a particular directory

Hi all,

I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file.

Are there any options available with the "find" command to do this..


Thanks in advance for your help

Pavan
  #2 (permalink)  
Old 10-07-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
Code:
ls -1 -t | tail -1
  #3 (permalink)  
Old 10-07-2006
pavan_movva pavan_movva is offline
Registered User
  
 

Join Date: Oct 2006
Location: India
Posts: 4
Thanks a lot shereenmotor.
  #4 (permalink)  
Old 03-23-2009
psiva_arul's Avatar
psiva_arul psiva_arul is offline
Registered User
  
 

Join Date: Jul 2007
Location: Bangalore, India
Posts: 97
We can use the below command also for find the latest file in particular directory

ls -gt | tail -1
  #5 (permalink)  
Old 04-08-2009
abinaya abinaya is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 24
Hi,

Try the below command

ls -ltr | head -1
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0