bash - find oldest file from list -
i've file list of files in different directories , want find oldest one. feels should easy shell scripting don't know how approach this. i'm sure it's easy in perl , other scripting languages i'd know if i've missed obvious bash solution.
example of contents of source file:
/home/user2/file1 /home/user14/tmp/file3 /home/user9/documents/file9
#!/bin/sh while ifs= read -r file; [ "${file}" -ot "${oldest=$file}" ] && oldest=${file} done < filelist.txt echo "the oldest file '${oldest}'"
Comments
Post a Comment