0

「L」で始まり「.pdf」で終わるいくつかのpdfを、ターミナルを使用してMacで結合しようとしています。私は次のことを試しました

find . -name "L*.pdf" | xargs -0  gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf

そして、私は次の出力を取得します

Error: /undefinedfilename in (./L01_Introduction.pdf\n./L02_Edges, Corners, Superpixels and Blobs.pdf\n./L03_SIFT, SURF, MSER.pdf\n./L04_Texture and Shape.pdf\n./L05_Feature Reduction.pdf\n./L06_Bag of Visual Words.pdf\n./L07_Clustering...)

Operand stack:
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2        %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push

Dictionary stack:
--dict:1167/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.06: Unrecoverable error, exit code 1

誰か助けてくれませんか?

4

1 に答える 1

0

xargsのパラメーターを使用する場合-0、入力引数 (ファイル名) が改行ではなくヌル文字で区切られていることが想定されます。

-print0上記の例を機能させるには、次のオプションを使用して find を使用できます。

find . -name "L*.pdf" -print0 | xargs -0 -t gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf

または、find コマンドの出力を で前処理してtr、改行をヌル文字に置き換えることもできます。

 find . -name "L*.pdf" | tr '\n' '\0' |xargs -0 -t  gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf 

注意:-tパラメータを使用すると、xargs コマンドは実行前に出力されます。

于 2014-06-13T17:39:37.720 に答える