Doomdoxrulz,

The first command (ls -1 /backup/*.dump) just creates a list of files in the backup folder that have the extension .dump. the output of the prior command is then sent to the next command (head -n -2) this cuts the list down to everything except the last 2 items in the list this is then sent to the final command which takes the list and runs the final (rm -f) command with the items in the list as the targets to delete.

heres a solution based on this post stackoverflow.com/…/delete-all-but-the-most-recen…

ls -tp /backup/*.dump | grep -v ‘/$’ | tail -n +4 | tr ‘\n’ ‘\0’ | xargs -0 rm -f

There is an explanation on that post that explains it in better detail but in simple terms it deletes all files but the most recent 3 files in the directory that have the .dump extension

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines