xargs | ぼぶろぐ

ぼぶろぐ

以前は、あいらぶLinux♪というタイトルでしたが、
最近はLinux以外のことも書いているので、タイトルを変更しました。
ぼぶちゃんのぶろぐでぼぶろぐです。

◆xagrs

このコマンドは、使い方がとても難しいです。
標準入力から渡されたファイル名などを引数とみなして、別のコマンドの引数として
利用することができます。

簡易マニュアルです。

# xargs -h
xargs: invalid option -- 'h'
Usage: xargs [-0prtx] [--interactive] [--null] [-d|--delimiter=delim]
[-E eof-str] [-e[eof-str]] [--eof[=eof-str]]
[-L max-lines] [-l[max-lines]] [--max-lines[=max-lines]]
[-I replace-str] [-i[replace-str]] [--replace[=replace-str]]
[-n max-args] [--max-args=max-args]
[-s max-chars] [--max-chars=max-chars]
[-P max-procs] [--max-procs=max-procs] [--show-limits]
[--verbose] [--exit] [--no-run-if-empty] [--arg-file=file]
[--version] [--help] [command [initial-arguments]]

Report bugs to <bug-findutils@gnu.org>.


使用例
# ls | xargs -I {} rm {}

これは、lsの結果を{}に順番に入れていき、削除していくものです。
例えば、rm -fr ./* とかでエラーが出る場合(ファイル数が多すぎる場合など)に
使用します。

使い方はこれ以外にたくさんありますので調べてみてください。
私ももっと勉強します。