Posted By

jaduks on 01/03/09


Tagged

command Bash awk


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Dorgendubal


Find Latest file in a directory


 / Published in: Bash
 

URL: http://unstableme.blogspot.com/2008/06/find-latest-file-in-directorybash.html

To find the latest file in a particular dir

  1. way 1:
  2.  
  3. $ ls -lrt | awk '{ f=$NF }; END{ print f }'
  4.  
  5. The above awk is to print the last argument of the last line
  6.  
  7. way 2:
  8.  
  9. $ ls -t1 | head -n1

Report this snippet  

You need to login to post a comment.