繁体   English   中英

如何从文件中grep一个单词并仅显示带有后缀而非整个行的单词?

[英]How to grep a word from a file and display only that word with its suffix not the whole line?

如何从文件中grep一个单词并仅显示带有后缀而非整个行的单词?

这是一个解释:

文件包括以下内容:(xxxxxx用于随机数据)

xxxxxx
xxxxxx
word1 word2 word3 device324432 word5 word6
xxxxxx
xxxxxx
word1 word2 word3 device957438546443 word5 word6
xxxxxx
word1 word2 word3 device11128546443 word5 word6
xxxxxx

如果我为设备grep,我会得到整条线。 如果我使用-o grep,我只会得到单词device(丢弃数字)

我需要的是使这个词一直到结尾。

device324432
device957438546443
device11128546443 

我使用awk '{print $4}'了效果,但是我想知道是否有“ grep”选项。

-o与匹配后缀的表达式组合。

grep -o 'device[0-9]*'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM