Вот один способ сделать это с JSON
модуль perl
:
json_producing_process | perl -MJSON -lne 'print from_json($_)->{name}'
Используйте следующую команду:
diff file1 file2 | grep '<' | cut -c3-
Разность берет различие файлов file1 и file2, затем мы grep '<'
вывод первой команды, которая получит строки, которые принадлежат первому файлу только. Вывод затем питается к cut -c3-
усекать первые два символа так, чтобы' <' и '' были устранены.
Принятие файлов находится в отсортированном порядке, который можно использовать comm
команда, чтобы сравнить эти 2 файла и показать результаты, которые находятся в file1
но не в file2
.
$ comm -23 file1 file2
1
2
3
4
-23
переключатель говорит comm
опустить строки, которые находятся только в file2 (-2
) и строки, которые находятся в обоих (-3
).
Передайте один файл как шаблон к grep
:
grep -vwFf 2.csv 1.csv
1
2
3
4
От man grep
:
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file
contains zero patterns, and therefore matches nothing. (-f is
specified by POSIX.)
-w, --word-regexp
Select only those lines containing matches that form whole
words. The test is that the matching substring must either be
at the beginning of the line, or preceded by a non-word
constituent character. Similarly, it must be either at the end
of the line or followed by a non-word constituent character.
Word-constituent characters are letters, digits, and the
underscore.
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v
is specified by POSIX.)