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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing of all the files in the order of last update (including those in the subdiret
# 1  
Old 11-17-2008
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
# 2  
Old 11-17-2008
Hammer & Screwdriver

What about this command?

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

which will give output like:
Code:
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.
Code:
find . -exec stat -c "%F|%Y|%n" {} \; | sort -rn

with output like
Code:
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.
# 3  
Old 11-19-2008
Thanks,

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

Any other solution?
# 4  
Old 11-19-2008
You have to write something that creates a file mtime in epoch seconds, then formats it usefully:
Code:
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:
Code:
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

This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 11-20-2008
Thanks

Thank you very much for your help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory listing in the order of size

I want to display directory listing in the order of size. I do not have -S option in my version of UNIX. So I wrote a simple script. But it takes "| sort -n -k5,5" part as file names. Any suggestion? #!/bin/ksh cmd='ls -l *.TXT | sort -n -k 5,5' set -x $cmd return 0 (7 Replies)
Discussion started by: Soham
7 Replies

2. Shell Programming and Scripting

File listing in Ascending order

I have a multiple file with the following name like. file_0.csv file_1.csv file_2.csv file_3.csv file_4.csv file_5.csv file_6.csv file_7.csv file_7.csv file_8.csv file_9.csv file_10.csv file_11.csv file_12.csv file_13.csv file_14.csv (2 Replies)
Discussion started by: rakesh_arxmind
2 Replies

3. Red Hat

Listing all child pid and deleting it in reverse order

Hi , My problem is that I am not able to list all process id of any process. If you see pstree command it shows many process id under https. But if I run ps command its not listing all the process id for httpd. It is just listing the PPID and immediate child process id only. I... (4 Replies)
Discussion started by: pratapsingh
4 Replies

4. UNIX for Dummies Questions & Answers

Including files

Hi, Is it possible to include files (print with EOF, sort of like ssi) in perl/cgi? Thanks (1 Reply)
Discussion started by: marringi
1 Replies

5. Shell Programming and Scripting

PERL: including files

I am wondering how I can include external files in a perl script. I'm currently working on a website, and I'd like to put my menu items in a subroutine for example, and put that in another file such as menu.pl. That way, I can call the subroutine from each page (such as news.pl), and if I want to... (2 Replies)
Discussion started by: LNC
2 Replies

6. Shell Programming and Scripting

Find files including subdirectory and Delete

Hello Experts, I m newbie. Could u pls help me to write script on Sun solaris- I have backup directory "/var/opt/backup/" where files are backed up in different directory "backup1" "backup2" "backup3". I want to write a shell script which i will put in crontab and daily midnight it will... (1 Reply)
Discussion started by: thepurple
1 Replies

7. Shell Programming and Scripting

Read files including spaces

I am accessing two files. I am using read command to read from the files. For the first file, I need read the fields delimited by spaces, and for the other file, I need to read the whole line as a single field including the spaces. When I used read command for the second file, the spaces... (4 Replies)
Discussion started by: kumariak
4 Replies

8. Shell Programming and Scripting

Listing files in numerical order

Hi, I'm trying to write a ksh script to copy a specified number of files from one directory to another. The files are named in the convention <switchname>_log.<num> and the numbers are sequential single digit onwards. I figured I could find some parameter for ls which would list the files in... (3 Replies)
Discussion started by: Steve_H
3 Replies

9. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

10. Programming

Including lib files when compiling

I am using the C compiler included with AIX 4.3.3. I am unable to include libraries when I try to create the executable. Is there a switch that has to be used at compile time to make this happen?? Can anyone help?? (2 Replies)
Discussion started by: andrewl68
2 Replies
Login or Register to Ask a Question