1

I am not understand why we got the following strange characters in out log

example -

 ^[[1m  

or

 ^[(B^ 

or

 ^[[1m  

or

 ^[(B^[[

or

 ^[[1m

from the log: ( example )

STATUS OF SERVICES

^[(B^[[mAMBARI_METRICS...... STARTED
HDFS................ STARTED
YARN................ STARTED
ZOOKEEPER........... STARTED
^[[1m
STATUS OF COMPONENTS

^[(B^[[mAPP_TIMELINE_SERVER. STARTED,
DATANODE............ STARTED,
5
  • what command are you using when this happens: text editor? if so, just check using cat <logfile>, these are probably used to set text format attributes for display (color, bold, italic...) Commented Jan 22, 2018 at 11:47
  • 1
    They're terminal control codes indeed, ^[[1m sets bold etc. Whatever prints your log, probably prints them too, even though it doesn't usually make much sense in a file. Commented Jan 22, 2018 at 11:58
  • any choice to remove them ? or filter them ? Commented Jan 22, 2018 at 12:08
  • 1
    Where is bash in this? Commented Jan 22, 2018 at 12:32
  • Have a look in this post, you might get lucky : stackoverflow.com/questions/6534556/… Commented Jan 22, 2018 at 13:07

1 Answer 1

1

As ilkkachu commented, the program whose output you redirected to a log file was designed to write status formatted for a text-console display, not for logging into a file.

The ^[[1m is an example of an ANSI control-code sequence for setting display attributes (foreground or background colour, bold, underlined etc). The ^[ is a typical representtation of an ASCII control character, in this case Escape (Esc) which is used in the relevant ANSI standard as a control-sequence introducer (CSI).

So this behaviour is baked into whatever program you are using. You might try misleading that program about what sort of output device it is connected to and thus fool it into not emitting those codes. Many programs use a library known as curses which uses the value of the environment variable TERM

The common shells allow you to temporarily change the value of an environment variable for a single command without affecting subsequent commands:

TERM=dumb programname options
1
  • thank you , btw I am using - export TERM=xterm , so from reading your answer I understand that we not have good solution to filter the craze strings -:) Commented Jan 22, 2018 at 12:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.