Tanto locate
como xargs
têm um argumento para separar nomes de arquivos usando o caractere nulo em vez de espaço ou nova linha. Isso deve corrigir o problema com espaços em nomes de arquivos.
locate -0 /usr/share/icons/* | xargs -0 ls -d 2>&1 >/dev/null
de man locate
:
-0, --null
Separate the entries on output using the ASCII NUL character
instead of writing each entry on a separate line. This option
is designed for interoperability with the --null option of GNU
xargs(1).
de man xargs
:
--null
-0 Input items are terminated by a null character instead of by
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string,
which is treated like any other argument. Useful when input
items might contain white space, quote marks, or backslashes.
The GNU find -print0 option produces input suitable for this
mode.