[dundee] Help with Bash Shell

gordon dunlop zubenel at fedoraproject.org
Thu Mar 31 09:16:49 UTC 2011


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/dundee/attachments/20110331/f9b38c90/attachment.htm>


More information about the dundee mailing list