July 16th, 2003, 10:01 AM
Selecting only newest file
I was hoping someone could help me out. I am trying to figure out how to search for the newest file in a directory and save it as a variable. For example, if you do a 'ls -ltr', the last file listed would be the newest file. Does anyone know how to save just that file name in a variable?
July 16th, 2003, 04:00 PM
foo=`ls -tr | tail -1`
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
July 16th, 2003, 05:44 PM