on-internet
← Community

Remove first and last quote (") from a variable

Stack Overflow ·

Below is the snippet of a shell script from a larger script. It removes the quotes from the string that is held by a variable. I am doing it using sed, but is it efficient? If not, then what is the efficient way? #!/bin/sh opt="\"html\\test\\\"" temp=`echo $opt | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/'` echo $temp

Comments

Sign in or sign up to comment and upvote.

No comments yet.