XargsコマンドはLinuxでは動作しますが、Macでは動作しません。

XargsコマンドはLinuxでは動作しますが、Macでは動作しません。

私のMacでは、次のxargsコマンドを実行しました。

echo replace | xargs -n 1 -I {} echo "asdf asdf adf asdf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf adf asdf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf{} asd"

文字列全体を印刷する代わりに、以下のように出力されます。

asdf asdf adf asdf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf adf

Linuxシステムで同じことを試み、期待した結果を得ました。 Macでこれを実装する方法を教えてください。

asdf asdf adf asdf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf adf asdf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdf asdf asdf asdf adf asdfreplace asd

ベストアンサー1

xargs(1)マニュアルページから

 -I replstr
         Execute utility for each input line, replacing one or more
         occurrences of replstr in up to replacements (or 5 if no -R
         flag is specified) arguments to utility with the entire
         line of input.  The resulting arguments, after replacement
         is done, will not be allowed to grow beyond 255 bytes;

その後、コマンドで生成された文字を計算すると、

$ wc -c out
     255 out

だから記録制限に達しました。解決策はこれを行うか(なぜそれほど長い議論が必要なのですか?)、いくつかのLinuxバージョンをインストールしてxargs呼び出すことはありません。

おすすめ記事