Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
06-08-2008, 02:02 PM
#1
LQ Newbie
Registered: Jul 2004
Posts: 6
Rep:
Use of quotation marks in bash
Hi all Im tryig to write a bash script to automate somewhat the creation of dvd's from avi source files, I am attmepting to use dvdauthor from my script wich uses a xmlfile called dvd.xml. I intendt to create the dvd.xml file from with in the script
a coorect example of the dvd xml file is below :-
Quote:
<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="your_video.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
</pgc>
</titles>
</titleset>
</dvdauthor>
here is the part of the script where i attempt to create the above dvd.xml file
Quote:
echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml
unfortunatley it doesnt quite work out as i expected i get the resulting xml file
Quote:
<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file=new.mpg chapters=0,0:10,0:20,0:30,0:40,0:50 />
</pgc>
</titles>
</titleset>
</dvdauthor>
as you can see from the above output the quotation marks are missing form the vob line is there any way i can avoid this ?
thanks for looking
06-08-2008, 02:15 PM
#2
Member
Registered: Oct 2006
Distribution: debian
Posts: 124
Rep:
Either escape the doublequotes you want to keep, as here:
Code:
echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file=\"new.mpg\" chapters=\"0,0:10,0:20,0:30,0:40,0:50\" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml
Note the \"'s.
Or else use single quotes as here:
Code:
echo '<dvdauthor>' > dvd.xml
echo ' <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />' >> dvd.xml
echo ' </pgc>' >> dvd.xml
Yet another option is to use a "here" document:
Code:
cat <<EOF >dvd.xml
<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
</pgc>
</titles>
</titleset>
</dvdauthor>
EOF
Har det gøy. Tischbein.
06-08-2008, 02:24 PM
#3
LQ Newbie
Registered: Jul 2004
Posts: 6
Original Poster
Rep:
Quote:
Originally Posted by
Tischbein
Either escape the doublequotes you want to keep, as here:
Code:
echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file=\"new.mpg\" chapters=\"0,0:10,0:20,0:30,0:40,0:50\" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml
Note the \"'s.
Or else use single quotes as here:
Code:
echo '<dvdauthor>' > dvd.xml
echo ' <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />' >> dvd.xml
echo ' </pgc>' >> dvd.xml
Yet another option is to use a "here" document:
Code:
cat <<EOF >dvd.xml
<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
</pgc>
</titles>
</titleset>
</dvdauthor>
EOF
Har det gøy. Tischbein.
THanks for that i used your last example it worked great
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 05:42 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News