例如:
file.txt 包含
this is a string
this is another string
grep "this is" file.txt 应该输出:
a string
another string
答案1
如果你有 GNU grep,那么使用这个(?<=)
“后视”应该工作:
$ echo -e "this is a string\nthis is another string"
this is a string
this is another string
$ echo -e "this is a string\nthis is another string" | grep -Po '(?<=this is).+'
a string
another string
一些正则表达式前瞻和后瞻信息这里
或者使用sed
sed 's/this is//'
或者
sed -n 's/this is//p'