To find the oldest file among the given files

April 29, 2009 at 05:58:54
Specs: Linux
Hi,

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

Thanks,
Teja.


See More: To find the oldest file among the given files

Report •


#1
April 29, 2009 at 08:53:28
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 } '


Report •

#2
May 6, 2009 at 21:37:30
Thank you its working :)

Report •

Related Solutions


Ask Question