[英]Cut and Awk command in linux
How can I extract word between 2 words in a file using cut and awk command. 如何使用cut和awk命令提取文件中2个单词之间的单词。
Lets say: I have a file with below content. 可以说:我有一个内容如下的文件。
This is my file and it has lots of content along wiht password and want to extract PASSWORD=MYPASSWORDISHERE==and file is ending here. 这是我的文件,它包含很多内容以及密码,并且想要提取PASSWORD = MYPASSWORDISHERE ==,文件到此结束。
exptected output 预期输出
1) using awk command linux. 1)使用awk命令linux。
2) using cut command linux. 2)使用cut命令linux。
MYPASSWORDISHERE==
Using awk
actually gawk
实际上使用
awk
gawk
awk '{match($0,/PASSWORD=(.*==)/,a); print a[1];}' input.txt
Using cut
you can try, I'm not sure if it works with your file 您可以尝试使用
cut
,但不确定它是否可以与您的文件一起使用
cut -d"=" -s -f2,3 --output-delimiter="==" input.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.