Using echo to print double quotes along with variable substitution

Hi,

I am generating html code using cshell, but i am having one problem while printing double quotes,

I need to write following code in file. where $var contains list of web address
<a href="$var">$var</a>

So i am using

echo "<a href="$var">$var</a>" > file.html

But with this " in href is not coming in file. Can any one please suggest me a way to do it. Is it possible to use anything else rather than " in echo command that can be used for variable interpolation also.

Thanks in advance.

Hi, is this what you are looking for?

 echo "<a href="\"$var\"">$var</a>" > file.html

Thanks for your reply , but still i am not able to do it,

Code is like

echo "<a href="file:\\\\$var">$var,/a>" > file1.html

So the output should be
<a href="file:\\\\www.abc.com">www.abc.com</a>
can you please suggest me for the above said code.

Try:

echo "<a href="\"file:\\\\\\\\$var\"">$var</a>" > file.html

-or-

echo '<a href="file:\\\\'"$var"'">'"$var"'</a>' > file.html

You can also use single quotes in the html string:

echo "<a href='$var'>$var</a>" > file.html
# or for the other string :
<a href='file:\\\\www.abc.com'>www.abc.com</a>

I Know it's not precisely what you asked for but it's correctly interpreted by the browsers.
What seems me strange is the backslashes. should the syntax not be :

<a href='file:///www.abc.com'>www.abc.com</a>