Listing of all the files in the order of last update (including those in the subdiret

I want to list all the files in the current directory including those in the subdirectories as well as a single lot in the order of last updated. (Not as separate list given by ls -lRt).

Any suggestion?

Thanks

What about this command?

find . -exec stat -c "%Y|%n" {} \; | sort -rn

which will give output like:

1226943267|./file73
1226943267|.
1226929499|./file70
1226929491|./file71
1226770385|./file63
1226770254|./file63.sav
1226677066|./file67
1226589199|./file68new
1226589041|./xab
1226589041|./xaa

If it is ok, then you can append a cut or awk to only print the filenames

The following version will show filetypes first.

find . -exec stat -c "%F|%Y|%n" {} \; | sort -rn

with output like

regular file|1226943267|./file73
regular file|1226929499|./file70
regular file|1226929491|./file71
regular file|1226770385|./file63
regular empty file|1226345695|./indic_file/ABCIND2008110901.TXT
regular empty file|1226345695|./indic_file/ABCIND2008110601.TXT
regular empty file|1225289894|./resnum/res4
directory|1226943267|.
directory|1225279229|./pass_var
directory|1225243924|./delete_extra

You could grep for "regular file", and then cut/awk to only include filenames.

Thanks,

However stat command is not available on all Unix e.g. AIX does not have it.

Any other solution?

You have to write something that creates a file mtime in epoch seconds, then formats it usefully:

filetime()
{
    perl  -e '
          use POSIX qw(strftime);
          $mtime = (stat $ARGV[0])[9];
          print strftime "%Y-%m-%d:%H:%M:%S ", localtime($mtime);
         ' $1
}
find . -name '*.shl' |\
while read filename 
do
	echo "$(filetime $filename) $filename"
done | sort 

output on a local directory:

2003-02-10:14:30:53  ./up.shl
2004-02-12:12:47:38  ./uzpbpia.shl
2004-07-29:09:06:14  ./uzppmt1.shl
2005-07-11:08:40:23  ./uzpbmgt.shl
2005-12-30:07:29:13  ./uzpftp.shl
2006-03-27:14:44:42  ./uzpnccl.shl
2006-03-30:11:04:28  ./push/BPMigration/shl/uzpnccl.shl
2006-03-30:11:07:36  ./push/BPMigration/shl/uzpbpft.shl
2006-03-31:11:33:17  ./push/BPMigration/shl/uzeblpt.shl
2006-05-30:12:16:17  ./uzpbrbt.shl
2006-05-30:12:33:55  ./uzpbpux.shl
2006-06-16:10:54:01  ./uzebpux.shl
2006-07-27:11:38:21  ./test.shl
2006-10-17:10:29:18  ./uzpcsf1.shl
2007-02-05:13:29:08  ./dt.shl
2007-02-22:10:28:54  ./uzpbpft.shl
2007-04-20:11:28:55  ./compile_all.shl
2007-04-23:08:40:29  ./comp.shl
2007-04-23:08:56:13  ./put.shl
2007-11-16:13:43:27  ./uzepteu.shl
2007-11-30:12:29:27  ./uzpsoal.shl
2007-12-05:11:04:16  ./push/csf/scripts/putPDF.shl
2007-12-07:11:23:52  ./newshl/stop_swjobs.shl
2007-12-07:11:24:28  ./newshl/restart_test.shl
2007-12-07:11:25:32  ./newshl/restart_swjobs.shl
2007-12-07:11:26:09  ./newshl/restart_jobs.shl
2007-12-12:09:49:45  ./push/pnm/c/mk.shl
2008-01-03:13:48:38  ./uzedele.shl
2008-01-08:11:27:23  ./uzrmadj.shl
2008-01-08:11:27:23  ./uzrnafx.shl
2008-01-08:12:02:37  ./HT671586_fix_mbil_inact_DF8703.shl
2008-01-08:12:02:37  ./LoadUzrccnt.shl
2008-01-08:12:02:37  ./export_tts_8685.shl
2008-01-08:12:02:37  ./gccomp.shl
2008-01-08:12:02:37  ./gencmpl.shl
2008-01-08:12:02:37  ./gencmplc.shl
2008-01-08:12:02:37  ./genlf40.shl
2008-01-08:12:02:37  ./get_pvcs.shl
2008-01-08:12:02:37  ./gjajobs.shl
2008-01-08:12:02:38  ./glbdata.shl
2008-01-08:12:02:38  ./glblsel.shl
2008-01-08:12:02:38  ./glbparm.shl
2008-01-08:12:02:38  ./glolett.shl
2008-01-08:12:02:38  ./glrletr.shl
2008-01-08:12:02:38  ./guavrfy.shl
2008-01-08:12:02:38  ./gurjobs.shl
2008-01-08:12:02:38  ./ht566472_fix_status_8112.shl
2008-01-08:12:02:39  ./import_tts_8685.shl
2008-01-08:12:02:39  ./linkcob.shl
2008-01-08:12:02:39  ./linkcobn.shl
2008-01-08:12:02:39  ./noserv2.shl
2008-01-08:12:02:39  ./online_tts_8685.shl
2008-01-08:12:02:39  ./pnm.shl
2008-01-08:12:02:39  ./putPDF.shl
2008-01-08:12:02:39  ./putpdf.shl
2008-01-08:12:02:39  ./restart_ParseProcess.shl
2008-01-08:12:02:39  ./restart_gurjobs.shl
2008-01-08:12:02:39  ./restart_job.shl
2008-01-08:12:02:39  ./restart_jobs.shl
2008-01-08:12:02:40  ./restart_jobs2.shl
2008-01-08:12:02:40  ./restart_swjobs.shl
2008-01-08:12:02:40  ./restart_swjobs_CR7812_tmsdev.shl
2008-01-08:12:02:40  ./restart_swjobs_CR7812_tmsfast.shl
2008-01-08:12:02:40  ./restart_test.shl
2008-01-08:12:02:40  ./restart_test_orig.shl
2008-01-08:12:02:40  ./sleepunx.shl
2008-01-08:12:02:40  ./stop_ParseProcess.shl
2008-01-08:12:02:40  ./stop_swjobs.shl
2008-01-08:12:02:40  ./testswjobs.shl
2008-01-08:12:02:41  ./trunctab.shl
2008-01-08:12:02:41  ./uapdelq.shl
2008-01-08:12:02:41  ./uardqtm.shl
2008-01-08:12:02:41  ./ubancase.shl
2008-01-08:12:02:41  ./ubpcalc.shl
2008-01-08:12:02:41  ./uccomp.shl
2008-01-08:12:02:41  ./ucobcomp.shl
2008-01-08:12:02:41  ./usaschc.shl
2008-01-08:12:02:51  ./usaschi.shl
2008-02-18:11:48:39  ./uzpdele.shl
2008-03-06:11:22:43  ./fanal.shl
2008-03-14:08:22:36  ./minmax.shl
2008-03-31:13:18:37  ./ddiff.shl
2008-04-23:15:31:48  ./sunday.shl
2008-05-01:10:57:39  ./new_CSF.shl
2008-05-27:14:01:40  ./uzrutrf.shl
2008-05-31:16:21:30  ./test_let.shl
2008-05-31:19:14:38  ./mk.shl
2008-06-04:06:38:04  ./uzemn.shl
2008-06-10:09:41:28  ./uzemail.shl
2008-06-18:10:02:03  ./cour.shl
2008-07-03:11:40:08  ./email.shl
2008-07-07:10:25:04  ./sendemail.shl
2008-07-24:10:39:25  ./spew.shl
2008-07-29:13:38:55  ./uzeblpt.shl
2008-08-01:11:25:04  ./whatever.shl
2008-08-20:13:14:08  ./tmp.shl
2008-08-26:07:38:58  ./cifsChecker.shl
2008-08-28:12:06:22  ./uzpletd.shl
2008-09-05:10:55:03  ./uzrcour_soa.shl
2008-09-16:08:49:42  ./overlap.shl
2008-09-19:11:41:12  ./soa.shl
2008-10-03:09:53:45  ./badproc.shl
2008-10-13:08:50:51  ./tic.shl
2008-10-20:10:57:51  ./uzembil.shl
2008-11-18:08:41:40  ./cal_parse.shl
1 Like

Thank you very much for your help.