Double quotes is not present to the directed file

I have the below to direct the values to a xml file,

echo "<xml version="1.0">" >> /root/xml/sample.xml

but when the check the sample.xml file, the output looks like the below one(without double quotes)

<xml version=1.0>

but i want the output like

<xml version="1.0">

Any help on this??

Use single quotes:

echo '<xml version="1.0">' >> /root/xml/sample.xml
1 Like

Or, with heredoc...

$ cat <<'END' >> /root/xml/sample.xml
<xml version="1.0">
END

Basics

echo Unix  o/p Unix
echo "Unix"  o/p Unix
echo 'Unix'  o/p Unix
echo "'Unix'"  o/p 'Unix'
echo '"Unix"'  o/p "Unix"
echo ''Unix''  o/p Unix
echo ""Unix""  o/p Unix

how to get this dateTime format in enclosed

date '+%Y'-'%m'-'%d'T'%T'.'%N'

Required o/p

"2012-07-10T09:31:02.238158000"
 echo '\"$(date '+%Y'-'%m'-'%d'T'%T'.'%N')\"' 

This is not working for me

---------- Post updated at 09:42 AM ---------- Previous update was at 09:38 AM ----------

Below is my complete code inside a shell script

et=`date '+%Y'-'%m'-'%d'T'%T'.'%N'`
echo $et
( echo '<?xml version="1.0" encoding="utf-8"?> name="test" Date=$et>' ) > test.xml

Got the quotes wrong again :frowning:

 echo "\"$(date '+%Y'-'%m'-'%d'T'%T'.'%N')\"" 
1 Like

This is working

et=`date '+%Y'-'%m'-'%d'T'%T'.'%N'`
echo $et
( echo '<?xml version="1.0" encoding="utf-8"?> name="test" Date="'$et'">' ) > test.xml

---------- Post updated at 10:11 AM ---------- Previous update was at 09:47 AM ----------

How to get up to first six decimal point here

o/p

"2012-07-10T10:09:51.538600000"

required o/p

"2012-07-10T10:09:51.53860"