Find Latest file in a directory


/ Published in: Bash
Save to your folder(s)

To find the latest file in a particular dir


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.