Используйтеgrep
:
grep -Fwf file1 file2
изman grep
:
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by
newlines, any of which is to be matched.
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. If this option is used multiple times or is combined with
the -e (--regexp) option, search for all patterns given. The empty file contains zero patterns, and
therefore matches nothing.
-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.
Илиawk
:
awk 'NR==FNR{seen[$0]++} ($2 in seen)' file1 file2
В приведенном выше примере сначала мы читаем файл1 и сохраняем весь столбец1 из массива с именем , видимым , затем смотрим в файле2 его второй столбец, и если он соответствует сохраненный столбец1 из файла1 затем переходит к печати всей строки файла2.
У вас также есть команда join
, если оба файла отсортированы (, если нет, вы можете передать отсортированный вывод, sort
ing):
join -1 1 -2 2 file1 file2
изman join
-1 FIELD
join on this FIELD of file 1
-2 FIELD
join on this FIELD of file 2
если файлы не отсортированы:
join -1 1 -2 2 <(sort file1) <(sort file2)
Ваш вопрос все еще немного неясен для меня, и у меня недостаточно вопросов, чтобы спросить в комментариях о разъяснениях.
Хотя,
gnome-session
должен запустить gnome. Это то, что я использовал в прошлом. Однако это было для Gnome2 дней. С Gnome3 я отказался от корабля после недолгого использования, так что, вероятно, все по-другому.
В качестве альтернативы, если у вас есть только один configure DE, вам может сойти с рукstartx