541
Comment: created by Samus_
|
436
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Describe BashFAQ/099 here. <<Anchor(faq99)>> == How can I get the newest file from a directory? == Parsing the output of 'ls' is a bad practice, you should create a loop and compare the timestamps: {{{ saved_ts=0 for f in *; do f_ts=$(stat --format=%Y "$f") if ((f_ts > newest_ts)); then newest_ts=$f_ts newest_f=$f fi done }}} there you'll have the newest file at $newest_f, notice that when a file changes also changes its timestamp so this will get the last created or modified file in the directory. |
Hello dear visitor. I'm Mittie Odaniel. One on the very best things inside the world for me personally is drawing but I have not made a dime with it's. Office supervising is just how I generate. His wife and him live in Arizona. My husband and I maintain an internet business. You might want to examine it here: http://Thatch22.Webs.com/<<BR>><<BR>> <<BR>><<BR>> My blog ... [[http://Thatch22.Webs.com/|how to be a mystery shopper]] |
Hello dear visitor. I'm Mittie Odaniel. One on the very best things inside the world for me personally is drawing but I have not made a dime with it's. Office supervising is just how I generate. His wife and him live in Arizona. My husband and I maintain an internet business. You might want to examine it here: http://Thatch22.Webs.com/<<BR>><<BR>>
My blog ... how to be a mystery shopper