Sembra che jsonlintnon sia possibile gestire più file:
$ jsonlint -h
Usage: jsonlint [file] [options]
file file to parse; otherwise uses stdin
Nota che dice sempre file , mai file . Quando esegui un comando e reindirizza il suo output xargscome hai fatto, xargssemplicemente concatena tutto l'output del comando e lo passa come input a qualsiasi cosa tu gli abbia detto di eseguire. Per esempio:
$ printf "foo\nbar\nbaz\n"
foo
bar
baz
$ printf "foo\nbar\nbaz\n" | xargs echo
foo bar baz
Ciò dimostra che il comando eseguito da xargsera
echo foo bar baz
Nel caso di jsonlint, quello che vuoi fare non è jsonlint -q foo bar bazma
$ jsonlint -q foo
$ jsonlint -q bar
$ jsonlint -q baz
Il modo più semplice per farlo è usare findcome suggerito da @ fede.evol:
$ find . -name \*.json -exec xargs jsonlint -q {} \;
Per farlo è xargsnecessario utilizzare la -Ibandiera:
-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.
Per esempio:
$ find . -name \*.json | xargs -I {} jsonlint -q {}
Oppure, per gestire in modo sicuro nomi strani (che contengono ad esempio newline):
$ find . -name \*.json -print0 | xargs -0I {} jsonlint -q '{}'
sudo apt-get install jsonlint, il comando èjsonlint-phpe non hai bisogno del flag -q. È possibile utilizzarefind . -name \*.json | xargs -I {} jsonlint-php {}.