LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 06-08-2008, 02:02 PM   #1
dunryc
LQ Newbie
 
Registered: Jul 2004
Posts: 8

Rep: Reputation: 0
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
 
Old 06-08-2008, 02:15 PM   #2
Tischbein
Member
 
Registered: Oct 2006
Distribution: debian
Posts: 124

Rep: Reputation: 15
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 gy. Tischbein.
 
Old 06-08-2008, 02:24 PM   #3
dunryc
LQ Newbie
 
Registered: Jul 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by Tischbein View Post
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 gy. Tischbein.
THanks for that i used your last example it worked great
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH variables, quotation marks and cURL struggles matthias_k Programming 13 01-27-2013 04:56 PM
Execvp With Quotation Marks amitbern Programming 10 11-25-2005 10:28 AM
no quotation marks jdoe9898 Linux - Newbie 1 10-12-2005 03:07 AM
Quotation marks and strings - in C lazyuser Programming 5 01-25-2005 08:14 AM
quotation marks dont display in X Obi-Wan_Kenobi Slackware 1 08-31-2003 10:42 AM


All times are GMT -5. The time now is 02:06 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration