よくスペース混じりのファイルなんかの処理にfind -print0
やxargs -0
でNULL区切り文字を使いますが,
今回間に更に処理を入れて使えませんでした.
逐次実行でよかったらxargs -n1 -I{} rm '{}'
みたいにして括ればいいんですが,
今回は一度に処理したかったのでこの方法は使えません.xargsのmanを見るとdelimiterを指定できるのに気づきました.
ということで改行(\n
)を指定してやりたかったことが実現できました :)
よくスペース混じりのファイルなんかの処理にfind -print0
やxargs -0
でNULL区切り文字を使いますが,
$ find . -type f | xargs lsls: ./ho にアクセスできません: そのようなファイルやディレクトリはありませんls: ge にアクセスできません: そのようなファイルやディレクトリはありません./fuga ./piyo$ find . -type f -print0 | xargs -0 ls./fuga ./ho ge ./piyo
今回間に更に処理を入れて使えませんでした.
逐次実行でよかったらxargs -n1 -I{} rm '{}'
みたいにして括ればいいんですが,
$ find . -type f -print | grep -v fuga | xargs -n1 -I{} ls '{}'./ho ge./piyo
今回は一度に処理したかったのでこの方法は使えません.xargsのmanを見るとdelimiterを指定できるのに気づきました.
--delimiter=delim, -d delimInput items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, oran octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are notsupported. When processing the input, quotes and backslash are not special; every character in the input is taken literally. The -d option disablesany end-of-file string, which is treated like any other argument. You can use this option when the input consists of simply newline-separated items,although it is almost always better to design your program to use --null where this is possible.
ということで改行(\n
)を指定してやりたかったことが実現できました :)
$ find . -mmin -1440 -type f -print0 | xargs -0n1 file | grep -i audio | cut -f1 -d: | xargs -d\\n ls -1tr