I'm trying to extract foo from the string "foo-bar-baz" in bash.
Any ideas how to do it using string substitution or something similar (without external tools).
I tried this but it didn't work:
$ str="foo-bar-baz"
$ echo ${str%-*}
foo-bar
This also not work:
$ str="foo-bar-baz"
$ echo ${str#*-}
bar-baz
Any ideas how to get just bar?
 
     
     
    