[dundee] Help with Bash Shell
Robert Ladyman
it at file-away.co.uk
Thu Mar 31 07:56:12 UTC 2011
>
>
> While read data; do
>
> curl -X PUT http://couchdb:port/db -d $data
>
> done
>
>
>
> which works, after a fashion, in as much as it sends the JSON document to
> couchdb, but it fails 'cos the quotes are not... well quoted, if you see
> what I mean. What I need is the contents of $data to be wrapped in single
> quotes, but I can't figure out for the life of me how to do it. It's not '
> + $data + ' for example, as it would be in other languages.
>
>
>
Something like:
echo \' `cat $data` \'
(if $data were a file)
should get you what you want: note that ` is a back-tick (often above the
tab-key) not a single quote
If $data is a variable with some data....
"'$data'"
That is, double-quote single-quote $data single-quote double-quote. So you can
probably use:
curl -X PUT http://couchdb:port/db -d "'$data'"
if that fails, use the echo trick above and put the result into a new variable
QUOTED_DATA=`echo "'$data'"`
note the back-ticks around the right-hand statement
--
Robert Ladyman
File-Away Limited
3 Ralston Business Centre, Newtyle, Blairgowrie
Perthshire PH12 8TL SCOTLAND
Tel: +44 (0) 1828 898 158
Mobile: +44 (0) 7732 771 649
http://www.file-away.co.uk
============================================
Registered Office: 32 Church Street, Newtyle, Blairgowrie
Perthshire, PH12 8TZ SCOTLAND
Registered in Scotland, Company Number SC222086
More information about the dundee
mailing list