I have a lengthy (with about 1000 characters) clob
object stored in a table. I need to read this value through a bash
script. How can I do this?
I've tried using a normal SELECT
query. But then the output comes as multiple lines. I cannot merge them as it does not produce the exact text in the database in special cases (e.g. if there is a space at the end of single line)
e.g.
abcd
efg
hijk
If I merged the lines with sed ':a;N;$!ba;s/\n//g;'
, this becomes abcdefghijk
when the actual text is abcdefg hijk
.
What is the best approach for doing what I'm trying to do here.
Since I couldn't find a way around using the above method, I managed to do what I want using a different approach.
Since the space character was the problem, and since I am the one who is inserting those clob
s, instead of inserting the text directly, I've first base64
encoded the text and inserted the encoded text into the table.
I could use the same SELECT
query after this. I had to perform a base64
decode on the select output to get the original text.