LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-27-2005, 06:29 PM   #1
gbhil
Member
 
Registered: Jan 2005
Location: /dev/input/chair0
Distribution: Slackware, Gentoo, Vector, Roll-your-own-with-GNU binutils
Posts: 174

Rep: Reputation: 30
Bash Scripting - echo command question


I'm in the process of writing a bash script to automagically generate the openbox3 menu. Consider the following snippet:
Code:
# Start of menu
cat << EOF > ${MENUFILENAME}
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/X11R6/share/openbox/menu.xsd">

EOF
echo "<menu id="root-menu" label=${MENUTITLE}>" >> ${MENUFILENAME}
I'm defining variables like so:
Code:
# Set var defaults
MENUFILENAME="${MENUFILENAME:=${HOME}/.config/openbox/menu.xml-autogen}"
MENUTITLE="${MENUTITLE:=openbox3}"
the output, which is written to the correct file:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/X11R6/share/openbox/menu.xsd">

<menu id=root-menu label=openbox3>
The problem -
openbox3's menu is in xml. I need the output to retain the double quote marks.
Desired format:
Code:
<menu id="root-menu" label="openbox3">
I'm sure (and hopeful) that the solution is simple, but it's eluding me. I thank anyone in advance for any input on how to echo the double quotes to the output file!
 
Old 04-27-2005, 06:33 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Just a suggestion. If you don't want bash to try to interpret what's inside the quotes, but replicate what's inside the quotes instead, try escaping the quotes with the backslash, like so:
\"http://openbox.org/\"
 
Old 04-27-2005, 07:27 PM   #3
gbhil
Member
 
Registered: Jan 2005
Location: /dev/input/chair0
Distribution: Slackware, Gentoo, Vector, Roll-your-own-with-GNU binutils
Posts: 174

Original Poster
Rep: Reputation: 30
thanks. I had tried the escape character, but I had used it wrong i.e. - \"www.bash.org"\
thanks again for setting me straight!
 
  


Reply



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
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
Bash Script, no new line for echo command jorisb Linux - General 5 11-05-2005 12:08 AM
A Bash Scripting Question steve_f60 Linux - Newbie 4 05-26-2005 06:57 PM
Bash command scripting otisthegbs Linux - General 6 07-06-2004 12:06 AM
Bash Scripting Question RefriedBean Programming 6 09-11-2002 09:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration