I have this part of a script which worked for a couple of weeks, but now stopped working:
find /media/2C1F-444F/usb_musik/newMusik -type f -printf '%T+ %p\n' | sort | head -n 5 | awk '{print $2}' | xargs sudo rm -v
It will find in the path files print a list sorted by oldest first and show only 5 and then delete them.
Now the output is
rm: cannot remove
/media/2C1F-444F/usb_musik/newMusik/N/Neil: No such file or directory
I changed a bit the code in awk print $2 changed to $3
find /media/2C1F-444F/usb_musik/newMusik -type f -printf '%T+ %p\n' | sort | head -n 5 | awk '{print $3}' | xargs sudo rm -v
which throws the error:
rm: cannot remove
Young/Mirror_Ball/09.Throw_Your_Hatred_Down.flac: No such file or directory
Checking on the directory, the files are there and are the oldest so should be ok to delete.
How is it possible that a script does not work any more? On the device the script stay where not update or upgrade done!
After deleting manually the files and started the command again (the first with awk $2) deleting worked again. The difference is the space in the path were it did not work - the second have underline and it rm, but not sure if it have to do with this.
removed '/media/2C1F-444F/usb_musik/newMusik/_VA/Australien/Various-Hits_From_Down_Under/09.Jimmy_Barnes-It_Will_Be_Alright.flac'
removed '/media/2C1F-444F/usb_musik/newMusik/_VA/Australien/Various-Hits_From_Down_Under/10.Air_Supply-All_Out_of_Love.flac'