Reputation: 5066
simple question, but my sed command is not working :(
echo "some_class" | sed -e 's/.+\_\(.+\)/\1/'
I want everything that happens to be after _ character. Please, how can I fix my code to work? Thank you.
In this case, "class" is the right answer.
Upvotes: 2
Views: 297
Reputation: 195199
this sed line works for your example:
sed 's/.*_//'
with your example:
kent$ echo "some_class"|sed 's/.*_//'
class
Upvotes: 3
Reputation: 531858
You don't need sed
; you can use parameter expansion to return the substring beginning with the first _
:
foo=some_class
echo "${foo#*_}"
Upvotes: 3