jsonlintを使用してディレクトリ内のファイルを束ねる(再帰的に)。xargsコマンドの長さの制限
find ./config/pages -name '*.json' -print0 | xargs -0I % sh -c 'echo Linting: %; jsonlint -V ./config/schema.json -q %;'
それは、ほとんどのファイルが、私は次のエラーを取得するいくつかのファイルのために動作します:
Linting: ./LONG_FILE_NAME.json
fs.js:500
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '%'
長いファイル名で失敗するように見える私は、次のコマンドを書きました。これを修正する方法はありますか?ありがとう。
編集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; this is implemented by concatenating as much of the argument containing replstr as possible, to the con-structed arguments to utility, up to 255 bytes. The 255 byte limit does not apply to arguments to utility which do not contain replstr, and furthermore, no replacement will be done on utility itself. Implies -x.
編集2: 部分的なソリューションを提供します。以前よりも長いファイル名をサポートしますが、必要なだけ長くはありません。
find ./config/pages -name '*.json' -print0 | xargs -0I % sh -c 'file=%; echo Linting: $file; jsonlint -V ./config/schema.json -q $file;'
が見える、それはxargsのではありませんxargsの –
は、私はこの問題だけではない優れたソリューションを考え出しました。編集を参照してください。 –
'-n 1'を渡すことで、' xargs'に一度に1つのjsonファイルを処理するように指示できます。あるいは、一度に '-n 20'を渡すことで、ある時点で破損点よりも少ない数のファイルを作成することができます。 – alvits