I am receiving a simple output from an Oracle Database, for some reason the output goes down to a new line and I cannot remove that return character.
This is what I've already tried:
sed 's/^M//g'
sed 's/\r//g'
sed 's/\n//g'
sed 's/\r\n//g'
sed 's/\r$//'
tr -d '\r' < infile > outfile
sed -i.bak 's/\r$//g' <filename>
sed 's/\r$//g'
I then tried dos2unix
but still nothing...
By converting the output in hexadecimal I can see that the misterious character is actually a CRLF, but none of the previous "CRLF removing" solutions seem to work.
- The normal output
- The output converted in hexa
Thank you in advance for your help! :)
CodePudding user response:
To remove the CRLF bytes, it's much easier in Perl:
perl -pe 's/\x0d\x0a//g'
Or you can run sed
and tr
:
sed 's/\r$//' file | tr -d '\n'
C2 A7
in UTF-8 corresponds to U 00A7
or SECTION SIGN
in unicode.
Specify both bytes to sed to remove it:
sed 's/\xc2\xa7//g'
CodePudding user response:
To delete all line feed and carriage return characters:
tr -d '\r\n' < old > new
Any POSIX tr can also take octals:
tr -d '\015\012' < old > new