I am trying to get quotes around a variable to make is just like I typed it in the terminal to get this script to work. it shows " quotes around the varibale " but still does not see it as quotes, as far as I can figure out because it does not work.


echo ${hs}${hex}
echo  "\" #${hex} \""
echo  "\"#${hex}\""
#one way trying
hsetroot -solid "\"${hs}${hex}\""
#another way of trying
hsetroot -solid "\""${hs}${hex}"\""

either way I put the " qoutes " around the variable, as you can see they both come up with quotes on both sides, and it still does not work. Yet if I type the "#31064d" into the terminal putting it where it needs to be then it works. output:

" #31064d "
Bad color ("#31064d") 
Bad color ("#31064d")

this works it is a good color code

userx@bw2-crunchbang:~/testscript$ hsetroot -solid "#31064d"

HOW do I format it in script so a program that needs the pram to be in quotes sees it in quotes?

I tried writing it this way too.

echo "\""#${hex}"\""
hsetroot -solid "\"#${hex}\""


Bad color ("#12eba5")

you see the " quotes " are still added around the numbers and letters like typing it into the terminal yet I get a nope, not working.

I've tried the ' ' and the marks too, no go.

  • hsetroot -solid "#"${hex}"" that is how, as I just figured it out. no more help needed this is answered that its. coffee time.
    – uxserx-bw
    Dec 17, 2013 at 1:24
  • Your question is inconsistent. You say you want the program to see the quote marks, but you give an example of a program that doesn't want the quote marks. Why do you think you need to pass quote marks to the program? What problem are you trying to solve? Dec 17, 2013 at 1:33
  • one if everybody read my comment they'd see I already solved my problem all by myself. two: I already show you in the question how one has to write " quote " makes around the item that program is needing so that it sees it.
    – uxserx-bw
    Dec 17, 2013 at 14:11
  • hsetroot -solid "#"${hex}"" is a weird way of writing hsetroot -solid \#${hex} (is is exactly equivalent) or hsetroot -solid "#${hex}" (which is what you really need). You don't want to pass quotes to the hsetroot command, it complains when you do. The double quotes are parsed by the shell, they are not passed to the command (unless you write things like \", in which case the command receives quotes that it doesn't know how to deal with). Dec 17, 2013 at 14:29

3 Answers 3


Take out the literal quotes: they are causing the error.

The shell uses the quotes to escape certain characters (the hash in this case which would otherwise be seen as the beginning of a comment), among other things. When the shell invokes another command and passes a quoted argument to it, it does not include the literal quotes, they are stripped off.

You just need this:

hsetroot -solid "${hs}${hex}"

You are misunderstanding the function of quotes. The shell uses double quotes to break up the command line into "words" (which may contain whitespace), then removes the quotes. Programs normally never see the quotes.


hsetroot -solid "#"${hex}"" that is how, as I just figured it out. no more help needed this is answered that its. coffee time. – uxserx-bw 12 hours ago that other dude that wrote. <<---- that is in the comment section ---/

looks like it might work too


whereas I did this


instead ---

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .