Delete new line

Hello All,

I have a file with records in delimited format with delimiter '^', there is a new line character in between data and causing issues while reading, any inputs in deleting new line character please?

Example:

Rec^IdealLoc^PersonID:118743^Long Description
\n
^7364563^4837567456^Long Description 
\n
^847653
Rec^City^PersonID:847565^Longdescription^523344^32564237645^LongD

Desired Output:

Rec^IdealLoc^PersonID:118743^Long Description^364563^4837567456^Long Description^847653
Rec^City^PersonID:847565^Longdescription^523344^32564237645^LongD

You are saying that there are extra <NL> chars in the file, on top of the usual ones, i.e. line terminators at the end-of-line?

Yes, I used '\n' just to imply new line

So you have legit newline characters in your file and illegit newline characters in your file.

So the first thing to do is to find out if there is a difference between the two because, if there isn't, how do you know which one's to delete?

Can you look at the file with a hex editor to actually see the ASCII value of the rogue characters? (Perhaps even ftp the file to another system (binary transfer) to use a hex editor on it.)

If there's a difference between legit and illegit characters then it must be possible to blow the illegit's away; but we need to know that first.

With that sparse specification, limited sample extent, just guessing the record structure (8 fields) and assuming the second record to be incomplete, how about

awk -F^ '{while (NF <= 7 && 1 == getline X) $0 = $0 X} 1' file
Rec^IdealLoc^PersonID:118743^Long Description^7364563^4837567456^Long Description^847653
Rec^City^PersonID:847565^Longdescription^523344^32564237645^LongD
1 Like