working with a script I've got this issue, most of the times when I run the script this is the output file I've got:
device_id,ip_address,serial_number
SEP0c1167231746, 148.000.000.32
SEP0c1167223fa5, 148.000.000.30
SEP0c1167224170, 148.000.000.30
SEP0c1167231d2e, 148.000.000.194
SEP0c1167233b9f, 148.000.000.31
CUV, 148.000.000.254
SEP0c1167231d32, 148.000.000.34
SEP501cbffcfa9c, 148.000.000.24
SEP00082fb67d5f, 148.000.000.21
SEP00082fb67701, 148.000.000.22
And this is exactly what I expect, but occasionally the file looks like this:
device_id,ip_address,serial_number
SEP0c1167231746
, 148.000.000.32
SEP0c1167223fa5
, 148.000.000.30
SEP0c1167224170
, 148.000.000.30
SEP0c1167231d2e
, 148.000.000.194
SEP0c1167233b9f
, 148.000.000.31
CUV
, 148.000.000.254
SEP0c1167231d32
, 148.000.000.34
SEP501cbffcfa9c
, 148.000.000.24
SEP00082fb67d5f
, 148.000.000.21
SEP00082fb67701
, 148.000.000.22
I tried to figure out what's going on, but it does not seem to be something regular, now I only want to handle with this, using Ghex I've identified the character that causes the problem.
Now I would like to replace all "0D" with Null and keep all "0A"
just as a note, I have tried using "dos2unix" but it didn't work.
Could you help me?
UPDATE: Using: sed -n -e '/,/!{N;s/\n//;}; /,/p' input
with a file like this:
device_id,ip_address,serial_number
SEP0c1167231746
, 148.000.000.32
,
SEP0c1167223fa5
, 148.000.000.30
,
SEP0c1167224170
, 148.000.000.30
,
SEP0c1167231d2e
, 148.000.000.194
,
SEP0c1167233b9f
, 148.000.000.31
,
CUV
, 148.000.000.254
,
SEP0c1167231d32
, 148.000.000.34
,
SEP501cbffcfa9c
, 148.000.000.24
,
SEP00082fb67d5f
, 148.000.000.21
,
SEP00082fb67701
, 148.000.000.22
I've got this output:
, 148.000.000.32
, 148.000.000.30
, 148.000.000.30
, 148.000.000.194
, 148.000.000.31
, 148.000.000.254
, 148.000.000.34
, 148.000.000.24
, 148.000.000.21
, 148.000.000.22
\r
sometimes and other times\n
. As otherwise, all fixes will be just patches without knowing for sure what's causing it, – user218374 Apr 7 '17 at 18:10