Computing.Net > Forums > Programming > To find the oldest file among the given files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

To find the oldest file among the given files

Reply to Message Icon

Name: Bhargav Teja
Date: April 29, 2009 at 05:58:54 Pacific
OS: Linux
Subcategory: General
Comment:

Hi,

How to find the oldest file among the given files that entered from cmd prompt(with multiple arguments) in shell script.

Thanks,
Teja.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 29, 2009 at 08:53:28 Pacific
Reply:

I'm making some assumptions. I'm assuming that all the files are in the current directory. I'm also assuming the filelist variable was input with a read statement like: read filelist


#!/bin/bash

filelist="file1.txt file2.txt file5.txt"

ls -1rt $(echo $filelist) | awk ' { print $1; exit } '


0

Response Number 2
Name: Bhargav Teja
Date: May 6, 2009 at 21:37:30 Pacific
Reply:

Thank you its working :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: To find the oldest file among the given files

how to find the filename? www.computing.net/answers/programming/how-to-find-the-filename/18246.html

how to find the sum of a 4 digit number www.computing.net/answers/programming/how-to-find-the-sum-of-a-4-digit-number-/1143.html

Batch File - Finding the IP address www.computing.net/answers/programming/batch-file-finding-the-ip-address/13900.html