3

[kubuntu] Bash script to sort oldest file in a directory

view full story
linux-howto

http://ubuntuforums.org – I'm making a Bash script and I need it to be able to keep logs. I want the log directory to contain at max 10 logs, and move all other logs to a sub-directory called "old". This is the section of the script that is suppose to do that: Code: mkdir -p old OLDEST=$(some_command) if [ $(ls -l *.txt | wc -l) -gt 10 ]; then   gzip -9 $OLDEST"   mv *.txt.gz old" fi My problem is to find out how to get the oldest file. So what do I have to put in "some_command" to get the name of the oldest file in the directory? And by oldest file I mean (Hardware)