ऐसा लगता है कि jsonlintकई फ़ाइलों के साथ सौदा नहीं कर सकते:
$ jsonlint -h
Usage: jsonlint [file] [options]
file file to parse; otherwise uses stdin
ध्यान दें कि यह हमेशा कहते हैं फ़ाइल , कभी नहीं फ़ाइलें । जब आप एक कमांड चलाते हैं और xargsजैसा कि आपने किया है, उसके आउटपुट को पाइप करते हैं, xargsतो बस कमांड के सभी आउटपुट को अलग कर देंगे और इसे इनपुट के रूप में पास करेंगे जो आपने इसे निष्पादित करने के लिए कहा है। उदाहरण के लिए:
$ printf "foo\nbar\nbaz\n"
foo
bar
baz
$ printf "foo\nbar\nbaz\n" | xargs echo
foo bar baz
इससे आपको पता चलता है कि कमांड द्वारा निष्पादित किया xargsगया था
echo foo bar baz
के मामले में jsonlint, आप क्या करना चाहते हैं नहीं है jsonlint -q foo bar bazलेकिन
$ jsonlint -q foo
$ jsonlint -q bar
$ jsonlint -q baz
ऐसा करने का सबसे आसान तरीका find@ fede.evol द्वारा सुझाया गया है:
$ find . -name \*.json -exec xargs jsonlint -q {} \;
xargsआपके साथ -Iध्वज का उपयोग करने की आवश्यकता है :
-I replace-str
Replace occurrences of replace-str in the initial-arguments with
names read from standard input. Also, unquoted blanks do not
terminate input items; instead the separator is the newline
character. Implies -x and -L 1.
उदाहरण के लिए:
$ find . -name \*.json | xargs -I {} jsonlint -q {}
या, अजीब नामों से निपटने के लिए (जिसमें उदाहरण के लिए newlines होते हैं) सुरक्षित रूप से:
$ find . -name \*.json -print0 | xargs -0I {} jsonlint -q '{}'
sudo apt-get install jsonlint, कमांड हैjsonlint-phpऔर आपको -q फ्लैग की आवश्यकता नहीं है। आप उपयोग कर सकते हैंfind . -name \*.json | xargs -I {} jsonlint-php {}।