LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
LinkBack 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 Squeeze
Posts: 5,405

Rep: Reputation: 212Reputation: 212Reputation: 212
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


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 11:15 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
Open Source Consulting | Domain Registration