I have binary log file with such similar lines which splitted by non-printable char "^A".
I see this symbol backlit white when I open file with command "less"
blah9234^Azzz123^A1=123
blah6344^Azzz123^A1=456
blah4555^Azzz123^A1=78912
I need convert it to:
zzz123^A1=123^Ablah9234
zzz123^A1=456^Ablah6344
zzz123^A1=78912^Ablah4555
so I need take first part
blah9234
add non-printable symbol ^A
^Ablah9234
and put it into the and of line
zzz123^A1=123^Ablah9234
to start I've tried to add ^A to the beginning of the line:
sed 's/^.*blah/^Ablah/' my.log > new.log
but it just adds '^' and 'A' and I got:
^Ablah9234^Azzz123^A1=123
and first ^A doesn't backlit white in less viewer.
Any advice's would be helpful. Thanks.
You can do this:
Or:
To understand the second example, you need to understand this. Basically,
$'\0xx'is equal to the control character that has that value in octal. For instance,$'\000'is theNULcontrol character.$'\001'is^A, theSOHcontrol character, etc.An even easier way is found here.
In this way, you type
ctrl-vthenctrl-ato insert^A.