I have a record like:

"evSchema"\1\"UAT" "evSN"\1\"uadb" "evDirsep"\1\"/" "evRootPath"\1\"/work_area/APP_UAT/" "evSchema"\1\"RMS13" "evUser"\1\"STAGE"

I want to replace \1\ with new line.

I tried using sed for this but it’s not working.

Anyone knows how to do that??

  • −1 for “not working” gibberish without specifying attempts made by the poster. – Incnis Mrsi Aug 24 '15 at 14:53
sed 's:\\1\\:\
:g' file

you will have to escape the backslashes in your match pattern. In the replacement, that's a backslash followed by a literal newline character. Some sed implementations, like GNU sed also support \n there as an non-standard alternative.


"UAT" "evSN"
"uadb" "evDirsep"
"/" "evRootPath"
"/work_area/APP_UAT/" "evSchema"
"RMS13" "evUser"
  • Hi I used the following comment: newevname=echo $evname | sed 's:\\1\\:\:g' Here $evname stores the record and I am using newevname to store the value in a file. the command is giving the below error: sed: 0602-404 Function s:\1\:\:g cannot be parsed. kindly advise how to proceed – Shaurabh Das Aug 25 '15 at 9:32
  • Hi I tried using the below comment: – Shaurabh Das Aug 25 '15 at 9:33
  • I assume, you are using bash: For assigning the output of a command to a variable, it should be: newevname=$(echo $evname | sed ... ) , for redirecting the output to a file, use echo $evname | sed ... > file – Fiximan Aug 25 '15 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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