What you say is essentially
rm -rw-r--r-- 1 user group1 14 Mar 11 09:54 the_file_20130311.bz2
In other words. Remove recursively files named:
If there was a
-w flag to rm and the other oddities in
A better option could be to use
ls -t. Do not worry about it not being on separate lines as
ls detect whether it's output is to a tty or not.
Demonstrated by e.g.:
ls -t | cat
But then another problem arises, and that is the fact you are not in the correct directory. So what you say is actually remove files in current directory which is named the same as the 6 last in
So ensure you are in correct path first, or, another option if you can install the GNU
find on your system would be something in the direction of:
find /path/to/files -maxdepth 1 -type f -name 'the_file_*' -printf '%T@ %p\n' |
sort -nr | head -n6 | cut -f2- -d" "
Note that you need the full path to get correct listing.
Then; if that looks OK add it to a