How do I remove the first and the last quotes?
echo "\"test\"" | sed 's/"//' | sed 's/"$//'
The above is working as expected, But I guess there must be a better way.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can combine the
sedcalls into one:The command you posted will remove the first quote even if it’s not at the beginning of the line. If you want to make sure that it’s only done if it is at the beginning, then you can anchor it like this:
Some versions of
seddon’t like multiple commands separated by semicolons. For them you can do this (it also works in the ones that accept semicolons):