The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-17-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink

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.