Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

share|improve this question
won't this go to – 太極者無極而生 Oct 5 '11 at 21:37
I don't know. Shell scripts, especially small ones like this, are a fine line. – Yitzchak Oct 5 '11 at 21:41
up vote 2 down vote accepted

try the below -

sed  's/\\n/\n/g' file.txt > blob.txt
share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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