sed如何实现grep -o的功能.
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/03 20:46:47
sed如何实现grep-o的功能.sed如何实现grep-o的功能.sed如何实现grep-o的功能.grep的-o选项:-o,--only-matchingShowonlythepartofamat
sed如何实现grep -o的功能.
sed如何实现grep -o的功能.
sed如何实现grep -o的功能.
grep 的 -o 选项:
-o, --only-matching
Show only the part of a matching line that matches PATTERN.
$ echo "hello" | grep -o "he"
he
sed利用正则表达式和group功能同样可以实现:
$ echo "hello" | sed -n 's/.*\(he\).*/\1/;p'
he