Я извлекаю строку из нескольких файлов, но единственным нежелательным побочным эффектом является имя файла, предшествующее выводу. Как я могу подавить вывод имени файла, используя только grep?
$ grep -i lp lpNet*
lpNet:This was printed via the internet using the lp command.
lpNet:I believe lp doesnt care what the device is.
lpNet1:This was printed via the internet using the lp command.
lpNet1:I believe lp doesnt care what the device is.
lpNet2:This was printed via the internet using the lp command.
lpNet2:I believe lp doesnt care what the device is.
lpNet3:This was printed via the internet using the lp command.
lpNet3:I believe lp doesnt care what the device is.
Я решил эту проблему, используя cat lpNet * | grep lp Мне просто интересно, есть ли более эффективный путь для достижения того же эффекта
Поведение по умолчанию должно распечатать имя файла, когда дали несколько аргументов файла - для подавления этого, можно добавить -h
или - опция
без имен файла От Output Line Prefix Control
раздел grep страницы руководства:
-h, --no-filename
Suppress the prefixing of file names on output. This is the
default when there is only one file (or only standard input) to
search.