Ah! This is a shell pipe! It’s composing several smaller commands together, cool stuff.
-
ls -1
is the grep-friendly version of ls, it prints one entry per line, like a shopping list. -
head
takes a set number of entries from the head of a list, in this case2 items.negative two, meaning “all but the last two.” -
xargs
takes the incoming pipe and converts it into extra arguments, in this case applying those arguments torm
.
So, combined, this says “list all the .dump files, pick the first two, all but the last two, and delete them.” Presumably the first are the oldest ones and the last are the newest, if the .dump files are named chronologically.
Won’t this delete the two newest files, as opposed to everything except the two newest files?