I'm writing a bash script that will deal with blob data that needs to be written to a file. The data inserted into the blob is separated by newlines. The command line mysql -e select blobfield from datatable > file.txt returns data of the form foo\nbar\nbaz\nmoo.
I would like to write it out to a file that looks like
foo
bar
baz
moo

This obviously looks like a regex job, but how do I replace \n with \n?

link|improve this question

won't this go to StackOverflow.com? – 動靜能量 Oct 5 '11 at 21:37
1  
I don't know. Shell scripts, especially small ones like this, are a fine line. – Yitzchak Oct 5 '11 at 21:41
feedback

1 Answer

up vote 2 down vote accepted

try the below -

sed  's/\\n/\n/g' file.txt > blob.txt
link|improve this answer
Thanks. It works, but it goes to stdout, not blob.txt. Why not? – Yitzchak Oct 5 '11 at 21:45
sorry...misunderstood question...see update. – bryan Oct 5 '11 at 21:49
Thanks for the help. – Yitzchak Oct 5 '11 at 22:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.