-1

Data sample input:

Name    mobile  url message text
test11  1234567890  www.google.com  "Data Test New
Date:27/02/2020
sample1: 1bags
sample2: 20bags
Regards
The test user user user Sangha
Ph:091 : 123456789"
test12  1234567891   www.google.com  hello

My output should be

Name    mobile  url message text
test11  1234567890  www.google.com  "Data Test New\nDate:27/02/2020\nsample1: 1bags\nsample2: 20bags\nRegards\nThe test user user user Sangha\nPh:091 : 123456789"
test12  1234567891  www.google.com  hello

I have used the below command but it's not working

awk '!/"$/{sub(/$/,"\\n");printf "%s",$0;next}1' file

I have used several other commands as well, but none of them are working in my case

phuclv
  • 37,963
  • 15
  • 156
  • 475
user13000875
  • 387
  • 2
  • 14
  • Does this answer your question? [Count number of line in txt file when new line is inside data](https://stackoverflow.com/questions/65035029/count-number-of-line-in-txt-file-when-new-line-is-inside-data) – Ryszard Czech Nov 30 '20 at 22:35

1 Answers1

0

Using gnu-awk, you may do this:

awk -v RS='"[^"]*"' '{gsub(/\r?\n/, "\\n", RT); ORS=RT} 1' file

Name    mobile  url message text
test11  1234567890  www.google.com  "Data Test New\nDate:27/02/2020\nItems: 1\nTotal: 3\nRegards\nABC DATa\nPh:091 : 123456789"
test12  1234567891   www.google.com  hello

Code Demo

anubhava
  • 761,203
  • 64
  • 569
  • 643