Как заключить споры в кавычки с xargs

@umair я не уверен, почему sdb показывает как съемный, мог Вы отправлять o/p этого сценария

for device in /sys/block/*
do
    if udevadm info --query=property --path=$device | grep -q ^ID_BUS=usb
    then
        echo $device
    fi
done
15
10.12.2014, 22:51
3 ответа

Simple use:

find . -size +1M -delete

Если вы настаиваете на использовании xargs и rm с помощью find, просто добавьте -print0 в вашу команду:

find . -size +1M -print0 | xargs -r0 rm --

Другой способ:

find . -size +1M -execdir rm -- {} +

Из man find:

-print0
    True; print the full file name on the standard output, followed by a null 
character (instead of the newline character that -print uses). This allows file names 
that contain newlines or other types of white space to be correctly interpreted by 
programs that process the find output. This option corresponds to the -0 option of 
xargs.
13
27.01.2020, 19:49

Вариант -0 из Xargs означает, что вывод из трубы интерпретируется как NULL Clanced элементы. В таком случае вам также необходимо создать вход для трубы с Найти ... -Print0 .

8
27.01.2020, 19:49

У меня было аналогичное требование, и в итоге я использовал переключатель -Iдля заполнителя, и я смог процитировать его.

find. -size +1M | xargs -I {} rm "{}"
32
27.01.2020, 19:49

Теги

Похожие вопросы