in reply to remove operating system delimiters?

Not to recommend this, but just to prove that it could be done. The following script accepts input from ls --color -p on STDIN, and strip the ANSI color commands with regex. I guess it's the regex that you are interested in.

use strict; binmode STDIN; # put STDIN in binary mode while (<STDIN>) { s/\033[^m]*m//g; # strip ansi color commands print $_; }

Replies are listed 'Best First'.
Re: Re: remove operating system delimiters?
by Anonymous Monk on Dec 05, 2003 at 16:35 UTC
    Thank you so much for the magic. That works very fine.
    Do you happen to know the patterns for any other OS delimiters for Linux redhat8?
    I figured I need to prepare for all the possible inputs.
    Wish you a happy holiday. ginger
      Those aren't OS delimiters. They are ANSI escape codes for displaying color. If you remove --color option from the ls command, they won't show up. You could also use --color=auto which causes to ls to only send color codes when it is talking to a terminal.
        Thank you so much for the professional explanation.
        I am wondering if there is any other weird chars I need to guard against in addition to the ANSI color codes.
        Is that possible that some other options of some other commands may include in the standardin some control chars
        I can not detect with regular perl regexp patterns?
        Have a good weekend. ginger