grep word 并检索匹配项和以下以制表符开头的行
grep word and retrieve the match and the following lines that start with a tab
我正在将我在工作中使用的一些术语收集在一个文件中:
terms.txt
term 1
here is the definition
definition continues
other
I will explain it here
blablabla
random word
etc
etc
blabla
我想 grep 例如“术语”并拉出定义,定义在下一行并以制表符开头
我曾尝试在此处使用 grep -iA 3 termterms.txt,但我想更精确一些。
当文件处于段落模式时,我通常按以下方式对段落进行 grep,但在 Linux 系统上使用 Perl:
perl -n00 -e 'print if /term/' file.txt
示例输出如下:
[user@localhost ~]$ perl -n00 -e 'print if /term/' file.txt
term 1
here is the definition
definition continues
您可以在此处找到有关段落模式的更多详细信息 - https://faculty.math.illinois.edu/~hildebr/computer/perltips.html
我正在将我在工作中使用的一些术语收集在一个文件中:
terms.txt
term 1
here is the definition
definition continues
other
I will explain it here
blablabla
random word
etc
etc
blabla
我想 grep 例如“术语”并拉出定义,定义在下一行并以制表符开头
我曾尝试在此处使用 grep -iA 3 termterms.txt,但我想更精确一些。
当文件处于段落模式时,我通常按以下方式对段落进行 grep,但在 Linux 系统上使用 Perl:
perl -n00 -e 'print if /term/' file.txt
示例输出如下:
[user@localhost ~]$ perl -n00 -e 'print if /term/' file.txt
term 1
here is the definition
definition continues
您可以在此处找到有关段落模式的更多详细信息 - https://faculty.math.illinois.edu/~hildebr/computer/perltips.html