You have two options. You can either call xargs with the -0 option, which splits the input into arguments using the NUL characters ( \0 ) as delimiters:
ls -rt | tr '\n' '\0' | xargs -0 rm -i
or you can use the -I option to split the input only on new lines ( \n ) and call the desired command once for each input line:
ls -rt | xargs -I_ rm -i _
The difference is that the first version only calls rm once, with all arguments presented as one list, and the second calls rm separately for each line in the input.
waldyrious Sep 05 '16 at 17:37 2016-09-05 17:37
source share