문제

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

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top