提取使用grep值 [英] extracting the values using grep
本文介绍了提取使用grep值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
样品字符串:A.TXT
Sample String : a.txt
Reading:RG1:+ /user/reading/Monday:12
Reading:RG1:- /user/**/Friday:12
Reading:RG1:- /user/**/*.txt:12
Reading:RG1:- /user/tet/**/*.txt:12
我期待提取字符串
I am looking to extract the string
after + or - what ever the string i want it
使用:
cat a.txt | grep RG1|grep '+'| cut -d':' -f3| cut -d'+' -f2 |sed -e 's/ //
我收到
/用户/读/周一
I am getting /user/reading/Monday
但我amlooking
But i amlooking
/用户/读/星期一:12
/user/reading/Monday:12
推荐答案
要解决您的命令,使用 -f3 -
,因为你想要的一切,从第三场结束行。
To fix your command, use -f3-
because you want everything from the 3rd field to the end of the line.
cat a.txt | grep RG1|grep '+'| cut -d':' -f3-| cut -d'+' -f2 |sed -e 's/ //'
这篇关于提取使用grep值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文