[linux] Re: Strip ansi
Kees Theunissen
theuniss op rijnh.nl
Ma Okt 24 10:18:56 CEST 2005
On Mon, 24 Oct 2005, Johan Wevers wrote:
>Kees Theunissen wrote:
>
>>Maar een 'cat' van diezelfde twee regels (met de escape sequences)
>>geeft op mijn scherm:
>>
>>/home/virus/collection/IRC-Worm.Matit.b
>> Found virus :Worm Generic
>>
>>Waarbij dat "Worm Generic" in rood is weergegeven.
>
>Kun je dat dan niet gebruiken om de ANSI sequenties eruit te slopen?
De kleur er uit slopen is geen probleem. Het ging me om de regel die er
boven staat. Als je de escape-sequences daar weg haalt krijg je:
/home/virus/collection/Trivial.35.gIRC-Worm.Matit.b
Kennelijk is dit geen listing van gevonden virussen maar de output
van het hele scan process. Panda heeft eerst een scan gedaan
van /home/virus/collection/Trivial.35.g zonder een virus te vinden.
Toen de cursor een stukje terug gezet, gewist tot het eind van de
regel en daarna de volgende filenaam geprint (IRC-Worm.Matit.b)
die hij ging scannen.
Bij dit soort output kan je niet volstaan met het weghalen van de
escape-sequences.
>
>Verder weet ik dat ls ook zoiets heeft: normaal zie ik files met een
>bepaalde extensie in kleur, maar als ik ls pipe naar less of more
>wordt dat eruit gehaald.
>
>Zou cat file | less > cleanupfile werken?
Nee. Less haalt die kleuren er niet uit, maar ls stopt ze er niet in!
Hier bij mij:
~$ alias |grep ls=
alias ls='/bin/ls $LS_OPTIONS'
~$ echo $LS_OPTIONS
--color=auto -F -b -T 0
En nu nog een stukje uit de ls(1) manpage:
--color[=when]
Specify whether to use color for distinguishing
file types. Colors are specified using the LS_COL-
ORS environment variable. For information on how
to set this variable, see dircolors(1). when may
be omitted, or one of:
none Do not use color at all. This is the
default.
auto Only use color if standard output is a ter-
minal.
always Always use color. Specifying --color and no
when is equivalent to --color=always.
Groeten,
Kees.
--
Kees Theunissen
F.O.M.-Instituut voor Plasmafysica "Rijnhuizen", Nieuwegein
E-mail: theuniss op rijnh.nl, Tel: 030-6096724, Fax: 030-6031204
More information about the Linux
mailing list