Removing character ' from a variable

Hello there,

I have a variable in the form of '/example/file.txt' . I want to remove the ' characters from the beginning and the end so that the my new variable becomes /example/file.txt . How can I do it in a script?

I know this is a fairly easy question, but i wasn't able to implement it.

You can use tr, read the man page.

Regards

or

search the forums :slight_smile:

am sure there are multiple threads about the same topic or related to that

using sed to search and replace the character(s)

in your case its going to be searching " ' " and replacing with ""

test example - note that you have to "escape" the ' character or the shell eats it, so to speak. \ = "escape" character

echo \'hello\'
echo \'hello\'  | tr -d \'