Reputation: 2388
I have a "my-variable-here" environment variable.
e.g.
my-variable-here=/var/log/test
I want to get the text between the equal sign and the 2nd slash. So in my example above, I want to get the text "/var".
how do I do it?
thanks very much
Upvotes: 2
Views: 2080
Reputation: 15769
you might want to use "cut" and slash as a delimiter
export my_variable_here=/var/log/test
part2=`echo $my_variable_here | cut -f2 -d"/"`
result="/$part2"
echo $result
Upvotes: 2