<br><br><div class="gmail_quote">On 31 March 2011 01:15, Gary Short <span dir="ltr"><<a href="mailto:gary@garyshort.org">gary@garyshort.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-GB"><div><p class="MsoNormal">All,</p><p class="MsoNormal"> </p><p class="MsoNormal">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</p>
<p class="MsoNormal"> </p><p class="MsoNormal">Head –n1 | store_to_couch.sh</p><p class="MsoNormal"> </p></div></div></blockquote><div>You can use sed to insert single quotes at the start and end of each line e.g.<br><br>
Head -n1 | sed -e s/^/\'/ -e s/$/\'/ file1 > file2 | store_to_couch.sh<br><br>Gordon<br><br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-GB"><div>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.<p class="MsoNormal">
</p><p class="MsoNormal">Can anyone help me?</p><p class="MsoNormal"> </p><p class="MsoNormal">Thanks,</p><p class="MsoNormal">Gary</p><font color="#888888"><p class="MsoNormal"> </p></font></div></div><br>_______________________________________________<br>
dundee GNU/Linux Users Group mailing list<br>
<a href="mailto:dundee@lists.lug.org.uk">dundee@lists.lug.org.uk</a> <a href="http://dundeelug.org.uk" target="_blank">http://dundeelug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/dundee" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/dundee</a><br>
Chat on IRC, #tlug on <a href="http://irc.lug.org.uk" target="_blank">irc.lug.org.uk</a><br></blockquote></div><br>