bash:使用grep从字符串之间提取文本
我有一个文本文件,内容如下:bash:使用grep从字符串之间提取文本,bash,unix,awk,sed,Bash,Unix,Awk,Sed,我有一个文本文件,内容如下: hello We're so excited to be learning computer science today HOORAY hooraaaay 我试图提取: We're so excited to be learning computer science today HOORAY “我们”和“万岁”之间的一切,包括这两个词 我正在使用命令: sed -n "/^We're so/,/^ HOORAY/p" file.txt
hello
We're so
excited to
be learning computer
science today
HOORAY
hooraaaay
我试图提取:
We're so
excited to
be learning computer
science today
HOORAY
“我们”和“万岁”之间的一切,包括这两个词
我正在使用命令:
sed -n "/^We're so/,/^ HOORAY/p" file.txt
但它不起作用(万岁后它不会停止)。我该如何解决这个问题?是否有其他方法接近该命令 这个简单的
sed
同样可以帮助您
sed -n "/We're/,/HOORAY/p" Input_file
解决方案二:也使用awk
awk '/We\047re/,/HOORAY/' Input_file