Insert quote into string variable in bash

bashbash-scriptingstring

Is there way of inserting a quote at the start and end into a string variable?

I have this variable say:

string="desktop/first folder"

If I echo this, it will display:

desktop/first folder

I need the string to be stored as:

"desktop/first folder"

Best Answer

If you don't do variable substitution, using single quotes as delimiters, so you can use double quotes in your string:

string='"desktop/first folder"'
Related Question