Problem:
I could always scroll characters to identify the char I want. However, now that I want to identify the carriage return, my way of doing something doesn't work:
function removeCarriageReturn()
{
word=""
while IFS= read -r -n1 char ; do
if [ "${char}" != "\r" ] ; then
word="${word}${char}"
fi
done <<<"$1"
printf '%s\n' "$word"
}
Result:
For some reason, I don't know if "$" is added before carriage returns, why? Here is the result (from Jenkins):
When char is parsed, for example, 8
++ '[' 8 '!=' '\r' ']'
When char is parsed - \ r
++ '[' $'\r' '!=' '\r' ']'
source
share