I have database backup files and I would like to create bash-script that returns different names from the most recent files in the current directory. For example:
/ home / user / toto / a_1.0 a_1.1 b_1.0 b_1.1 c_1.0 c_1.1
I want the script output to look like this:
/ home / user / toto / a_1.1 b_1.1 c_1.1
I read a reference from here and I was able to get the above result with this sample command:
#! / bin / bash find . -name "a_ *" -print0 | xargs -r -0 ls -t | head -1 find . -name "b_ *" -print0 | xargs -r -0 ls -t | head -1 find . -name "c_ *" -print0 | xargs -r -0 ls -t | head -1
I just changed the name template to the name of the different backup file, but how to delete all the files except for the file printed in the result above?