Sed does not find control character 0A

The file contains the feed sequence for the carriage return line hex 'DA'. Hexedit clearly shows two hexadecimal characters.

20 0D 0A 31

and

sed  -n '/\x0D/p' ./test.txt

Clearly identifies strings however

sed  -n '/\x0A/p' ./test.txt

will not find any rows.

To make this even more interesting after using sed to remove "0D", he did not find "0A" in the line:

20 0A 31

How sed can be used to remove 0D0A after a specific character string. The file has extraneous linear feeds after certain text. This creates 2 lines where one should be. The goal is to recreate one of two.

+4
source share
2 answers

sed ; \x0a.

Perl, -0777 , :

perl -0777 -pe 's/\x0d\x0a//'
+3

sed, python, \n , . , , :

sed 'H;1h;$!d;x; s/something\n/somethingelse/g'

sed ( ), . , . , , . :

  • H -
  • 1h - ,
  • $!d - , .
  • x -

:

$ cat file
Try to av-
oid word
splits.

, , :

$ sed 'H;1h;$!d;x; s/-\n//g' file
Try to avoid word
splits.

, :

$ sed 'H;1h;$!d;x; s/-\x0a//g' file2
Try to avoid word
splits.
+3

All Articles