我想在匹配字符串后打印完整的行
例如,我有这样的输入: -
www.google.com/images
www.google.com/images/12
www.yahoo.com/images/12
www.bing.com/images/34
www.google.com/images/12
www.google.com/images/imagescols
我想要这个输出: -
com/images
com/images/12
com/images/12
com/images/34
com/images/12
com/images/imagescols
请使用unix中的grep命令建议一种方法。
答案 0 :(得分:3)
您可以尝试以下剪切命令。
cut -d. -f3 file
OR
awk -F. '{print $NF}' file
OR
grep -oE '[^.]*$' file
示例:强>
$ cut -d. -f3 file
com/images
com/images/12
com/images/12
com/images/34
com/images/12
com/images/imagescols