Home > OS >  How to deal with the escape character of script log
How to deal with the escape character of script log

Time:02-07

Issue the following description:
1. Use script command on Linux can record the current user's commands and command echo, and the record to the log file is as follows:
$script
Through the cat can view operation record:

Through the vim editor will see a lot of escape character, as follows:


Problems come, now I want to have a program to read the log file, then line-by-line parsing the contents, but read data containing the H ^ ^ [[K data such as, how to eliminate this? For example:
# PE H ^ ^ [[Kwd
Is actually # PWD.
What do you have any tool or function or procedure can handle this control characters?

CodePudding user response:

From the top of a first!!!!!!

CodePudding user response:

Try with col

CodePudding user response:

Try iscntrl ()

CodePudding user response:

Try upstairs said

CodePudding user response:

The
reference 3 floor dark9527 response:
try iscntrl ()

Thank you, but this can't meet my needs, I log in control characters, not just to judge whether the control characters, according to the control character, control the cursor,

CodePudding user response:

After read directly, by judging whether visible characters, with no?

CodePudding user response:

Is to read the file, there is no difference between
You see ^ M, is the way of display control characters in VIM, detail can be passed in VIM: help digraph - table command to see
Can turn lots of pages, here to show only the first page
 
* digraph - table *
Char digraph hex dec official name ~
^ @ NU 0 0 x00 NULL (NUL)
^ A SH 0 x01 1 START OF HEADING (SOH)
^ B SX 0 x02 2 START OF the TEXT (STX)
EX C ^ 0 x03 3 END OF the TEXT (ETX)
^ D ET 0 x04 4 END OF TRANSMISSION (EOT)
^ E EQ 0 x05 5 ENQUIRY (ENQ)
^ AK 0 F x06 6 ACKNOWLEDGE (ACK)
BL ^ G 0 x07 7 BELL (BEL)
H ^ 0 x08 BS 8 BACKSPACE (BS)
^ I HT 0 x09 9 CHARACTER TABULATION (HT)
^ @ LF 0 x0a 10 LINE FEED (LF)
VT 0 ^ K x0b 11 LINE TABULATION (VT)
FF 0 ^ L x0c 12 FORM FEED (FF)
^ M 13 CR 0 x0d CARRIAGE RETURN (CR)
^ N SO 0 x0e SHIFT OUT of 14 (SO)
^ O SI 0 x0f 15 SHIFT (SI) IN
^ P DL 0 x10 16 DATALINK ESCAPE (DLE)
D1 0 ^ Q x11 17 DEVICE CONTROL ONE (DC1)

When you use the program to read the file can't meet ^ M such a string, met ^ M, is actually met CR (newline),

PE H ^ ^ [[Kwd this ^ H e, on behalf of the backspace to delete characters ^ [said ESC key [K should be ESC swallow characters

CodePudding user response:

The building Lord try [dos2unix files]

CodePudding user response:

Then solved? I also encountered this problem
  • Related