[dundee] Help with Bash Shell

'Gary Short' gary at garyshort.org
Thu Mar 31 09:26:39 UTC 2011


Nope that doesn't work either, puts the quote in the same place near the end
of the line. I wonder if the line is overflowing some stdin buffer or
something

 

From: dundee-bounces at lists.lug.org.uk
[mailto:dundee-bounces at lists.lug.org.uk] On Behalf Of gordon dunlop
Sent: 31 March 2011 10:09
To: Tayside Linux User Group
Subject: Re: [dundee] Help with Bash Shell

 

 

On 31 March 2011 01:15, Gary Short <gary at garyshort.org> wrote:

All,

 

I think the Bash Shell maybe the worst programming language I've ever used.
I'm trying to do something so simple and yet it's eluding me. I have a file
(results) which holds JSON documents, I want to take the first line of that
file and pass it to a bash script that will store it in couchdb, simple.
You'd think! So I have this line

 

Head -n1 | store_to_couch.sh

 

You can use sed to insert single quotes at the start and end of each line
e.g.

Head -n1 | sed -e s/^/\'/ -e s/$/\'/ file1 > file2 | store_to_couch.sh

Gordon


 

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.

 

Can anyone help me?

 

Thanks,

Gary

 


_______________________________________________
dundee GNU/Linux Users Group mailing list
dundee at lists.lug.org.uk  http://dundeelug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/dundee
Chat on IRC, #tlug on irc.lug.org.uk


!DSPAM:5,4d94454b269863196947667! 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/dundee/attachments/20110331/4010afd9/attachment.htm>


More information about the dundee mailing list