xargs -Jなしでpdftk検索から空白をエスケープします。

xargs -Jなしでpdftk検索から空白をエスケープします。

サブディレクトリ内のすべてのPDFをリンクしたいです。ファイル名にスペースを含めることができます。私にとって解決策は明らかです。

find . -name *.pdf -print0 | xargs -0 -J FILE  pdftk FILE cat output out.pdf

しかし残念ながら、私のバージョンのxargsは-Jオプションをサポートしていません。これを達成する他の方法はありますか?

私はこれを試しました

pdftk $(find . -name *.pdf -print0 | xargs -0  -I {} printf '%q ' {}  ) cat output out.pdf

しかし、pdftkはそれを脱出口がないかのように扱います。

ベストアンサー1

-Iあなたのためではありません。必要なものは次のとおりです。

find . -name '*.pdf' -type f -exec sh -c 'pdftk "$@" cat output /tmp/out.pdf' x {} +

以下はいくつかの免責事項です。

a) Your current working dir. != /tmp
b) The sh is run just once otw, the out.pdf will be overwritten by the last run.
c) Your sh stores the 1st -> $0, 2nd -> $1, 3rd -> $2, etc.

上記の問題をすべて解決できますが、始めるのにこれだけで十分です。

おすすめ記事