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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-06-2008, 03:48 PM
|
#1
|
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546
Rep:
|
bash: How to echo plenty of ' and " chars ?
Hello,
Sorry for the ultra n00b question, even if already programing.
I would like just to have a script that put that content into .festivalrc:
Code:
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
Hence, the script would be :
myscript.sh
Code:
#!/bin/sh
echo "(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")" > ~/.festivalrc
echo "(Parameter.set 'Audio_Method 'Audio_Command)" >> ~/.festivalrc
but this code of course do not work 
thank you
(and sorry for the n00b question again)
|
|
|
|
05-06-2008, 03:52 PM
|
#2
|
|
Member
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Rep:
|
Escape the quotes. For instance:
echo "This is a \"test\" using different 'kinds' of \"quotes\""
will output:
This is a "test" using different 'kinds' of "quotes"
So you'd need this:
#!/bin/sh
echo "(Parameter.set 'Audio_Command \"aplay -q -c 1 -t raw -f s16 -r $SR $FILE\")" > ~/.festivalrc
echo "(Parameter.set 'Audio_Method 'Audio_Command)" >> ~/.festivalrc
Last edited by rocket357; 05-06-2008 at 03:57 PM.
|
|
|
|
05-06-2008, 03:56 PM
|
#3
|
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546
Original Poster
Rep:
|
Quote:
Originally Posted by rocket357
Escape the quotes. For instance:
echo "This is a \"test\" using different 'kinds' of \"quotes\""
will output:
This is a "test" using different 'kinds' of "quotes"
|
Ahh and can you do this \' \' ?
since you can do :
echo '" this is a text "'
...
|
|
|
|
05-06-2008, 04:00 PM
|
#4
|
|
Member
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Rep:
|
Umm, yeah, but you wouldn't require \' since you're main quote is using double quotes.
You could look at it like this:
echo 'This is a \'single\' quoted line. I shouldn\'t have to escape "double quotes" '
echo "This is a \"double\" quoted line. I shouldn't have to escape 'single quotes' "
Last edited by rocket357; 05-06-2008 at 04:02 PM.
|
|
|
|
05-06-2008, 05:07 PM
|
#5
|
|
Member
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212
Rep:
|
Code:
cat <<! >~/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
or (if you don't want to expand SR and FILE):
Code:
cat <<\! >~/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
Last edited by radoulov; 05-06-2008 at 05:09 PM.
|
|
|
|
12-28-2008, 12:47 PM
|
#6
|
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546
Original Poster
Rep:
|
Quote:
Originally Posted by radoulov
Code:
cat <<! >~/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
or (if you don't want to expand SR and FILE):
Code:
cat <<\! >~/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
|
I put that in a script and it says taht " is somehow missing or end of file
nota: \ added to preserve "$"
Code:
cat <<! >~/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r \$SR \$FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
|
|
|
|
12-28-2008, 02:33 PM
|
#7
|
|
Member
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212
Rep:
|
What is the exact command you're running?
Here I'm using bash:
Code:
$ cat <<\! >~/.festivalrc
> (Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
> (Parameter.set 'Audio_Method 'Audio_Command)
> !
$ cat .festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
Notice that some shells will require double \\ to quote the heredoc if you use ! as a delimiting identifier.
|
|
|
|
12-29-2008, 02:40 AM
|
#8
|
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546
Original Poster
Rep:
|
Quote:
Originally Posted by radoulov
What is the exact command you're running?
Here I'm using bash:
Code:
$ cat <<\! >~/.festivalrc
> (Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
> (Parameter.set 'Audio_Method 'Audio_Command)
> !
$ cat .festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
Notice that some shells will require double \\ to quote the heredoc if you use ! as a delimiting identifier.
|
Actually I have to put the commands in a bash script, that willl be run afterwards with ./script or sh script, and will generate that .festivalrc file.
|
|
|
|
12-29-2008, 02:50 AM
|
#9
|
|
Member
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212
Rep:
|
Quote:
Originally Posted by frenchn00b
Actually I have to put the commands in a bash script, that willl be run afterwards with ./script or sh script, and will generate that .festivalrc file.
|
This is how I'm running it from a script:
Code:
$ ./s
generating /home/sysadmin/.festivalrc ... done
displaying the content of /home/sysadmin/.festivalrc
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
And this is the script:
Code:
#! /bin/bash
rcfile="$HOME/.festivalrc"
printf 'generating %s ... ' "$rcfile"
cat <<\! >"$rcfile"
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
!
printf 'done\n'
printf 'displaying the content of %s\n\n' "$rcfile"
cat "$rcfile"
|
|
|
|
| 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:06 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
|
|