[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#38706: error
From: |
Assaf Gordon |
Subject: |
bug#38706: error |
Date: |
Sun, 22 Dec 2019 12:49:48 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
tag 38706 moreinfo
stop
Hello,
On 2019-12-22 2:37 a.m., Garn-Bachmann wrote:
Inserting characters at the end leads to errors
cat ~/te.txt | sed 's|$|h|g'
h036
h110
h110
I suspect this is an issue with end-of-line characters
being "\r\n" (CR LF) in the input file.
The '$' regex matches the end of the line,
which would be AFTER the "\r". The text line becomes "0036\rh\n"
which causes the output you are seeing.
For example:
$ printf '%s\r\n' aaa bbb ccc | sed 's|$|h|g'
haa
hbb
hcc
---
There are many ways to remove the carriage return (\r) characters.
For example:
Using sed:
$ printf '%s\r\n' aaa bbb ccc | sed 's|\r|| ; s|$|h|g'
aaah
bbbh
ccch
Using "tr":
$ printf '%s\r\n' aaa bbb ccc | tr -d '\r' | sed 's|$|h|g'
aaah
bbbh
ccch
Or using the "dos2unix" programs.
---
If this solves the issue - great.
If not, please share the input file (te.txt) to help us
diagnose the issue better.
You can send it to me privately off-list if you prefer.
regards,
- assaf