简单的问题,但我的 sed 命令不起作用:(
echo "some_class" | sed -e 's/.+\_\(.+\)/\1/'
我想要恰好在 _ 字符之后的所有内容。请问,我怎样才能修复我的代码工作?谢谢你。
在这种情况下,“类”是正确的答案。
You don't need sed
; you can use parameter expansion to return the substring beginning with the first _
:
foo=some_class
echo "${foo#*_}"
this sed line works for your example:
sed 's/.*_//'
with your example:
kent$ echo "some_class"|sed 's/.*_//'
class