I would like to delete a certain number of the largest files in a directory.
I can get the filenames of the first ten with:
ls -S | head (or a richer albeit more complex to parse
ls -lS | head)
How would I pass those to rm ? via xargs ?
ls -S | head | xargs rm work (even with filenames with spaces etc?)
Is there a better / safer way ?
Sorry but I could not test this myself in fear of goofing (the directory has stuff I really don't want to zap).
I use macOS.