sed $ mismatch start of line with double quote

11 Views Asked by At

I am having a weird behavior with bash and sed (on a Debian9 machine), it may be something related to the file (file1.CSV) I'm using but I cannot figure out what.

Here we go, if I try to replace the endline with something through sed it mismatch the linestart (that is a "):

head app/datasets/liste_random/file0.csv  | sed 's/$/@/'

@id","stratum","block.id","block.size","treatment"
@PC_LR01","Piacenza_LR","PC_LR1",4,"COLC"
@PC_LR02","Piacenza_LR","PC_LR1",4,"COLC"
@PC_LR03","Piacenza_LR","PC_LR1",4,"SOC"
@PC_LR04","Piacenza_LR","PC_LR1",4,"SOC"
@PC_LR05","Piacenza_LR","PC_LR2",4,"SOC"
@PC_LR06","Piacenza_LR","PC_LR2",4,"COLC"
@PC_LR07","Piacenza_LR","PC_LR2",4,"COLC"
@PC_LR08","Piacenza_LR","PC_LR2",4,"SOC"
@PC_LR09","Piacenza_LR","PC_LR3",2,"SOC"

I looked for possible reasons but I could find nothing interesting, sure it is something stupid but I could not figure out what was the problem.

If I echo a line it works properly, so think it is the file

echo '"id","stratum","block.id","block.size","treatment"
"PC_LR01","Piacenza_LR","PC_LR1",4,"COLC"'  | sed 's/$/@/g'

"id","stratum","block.id","block.size","treatment"@
"PC_LR01","Piacenza_LR","PC_LR1",4,"COLC"@

Thank you so much in advance for any help!

0

There are 0 best solutions below