The following code removes new line with in double quotes
I am replacing newline character with in double quotes with 123.
intermediatenewline_remover () {
typeset Infile=$1
nawk -F"," '{ record = record $0
if ( gsub( /"/, "&", record ) % 2 )
{
record = record "123"
next
}
}
{
print record
record = ""
}' Infile
}
Here i am combining 4th and 5th field with "123" as seperator
nawk -F"|" '{print $2,$3,$4"123"$5}' OFS="|" file
Replacing Comma and seperator "123" with space.
The problem here is if data has "123" that will also be replaced with space.
I want only "123" seperator to be replaced.
nawk -F"|" '{gsub(",", " ",$3);gsub("123", " ",$3);print}' OFS="|" file
I tried using SUBSEP
This code instead of using value for SUBSEP "\034" its inserting "SUBSEP"
intermediatenewline_remover () {
typeset Infile=$1
nawk -F"," '{ record = record $0
if ( gsub( /"/, "&", record ) % 2 )
{
record = record "SUBSEP"
next
}
}
{
print record
record = ""
}' Infile
}
and how to handle this change in this code
nawk -F"|" '{print $2,$3,$4"123"$5}' OFS="|" file
nawk -F"|" '{gsub(",", " ",$3);gsub("123", " ",$3);print}' OFS="|" file