3
find . -type f -print0 | xargs -0 ls -ltr | head -n 10 | awk '{print
$NF}' | xargs rm

This command is giving me this:

xargs: 'ls' terminated by signal 13

However, it's executing fine. It's supposed to delete the 10 oldest files on the specific folder. Is there something to worry about? Is there a fix?

Server is running BuildRoot.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • A better way to sort files, especially lots of files - so many that xargs would issue multiple invocations of ls and you wouldn't get a total sort - can be found at https://unix.stackexchange.com/questions/22674/shell-script-for-moving-oldest-files – Mark Plotnick Sep 10 '18 at 19:35
  • Signal numbers other then 1, 2, 3, 6, 9, 14, and 15 are not portable. You need to explain what signal 13 is on your local machine. – schily Sep 10 '18 at 20:55

1 Answers1

1

I believe the issue is with the head command and the pipe. See https://stackoverflow.com/questions/27800726/ls-terminated-by-signal-13-when-using-xargs for more information.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Lewis M
  • 1,048