1851718 Members
2527 Online
104062 Solutions
New Discussion

Special characaters

 
SOLVED
Go to solution
Jerome Salyers
Advisor

Special characaters

i'm working with some software and i want to be able to manipulate the output of the top command a bit...

however, there are those pesky ^[[5C type characters that clog up the output... i can't find out what they are or, more importantly, how i can use a regex to manipulate the text they are attached to...

using my meager s/ / /g skills i can get rid of all of it but not the first ^[

any ideas?

thanks in advance

jerome
5 REPLIES 5
Andreas Voss
Honored Contributor

Re: Special characaters

Hi,

try this:

sed 's/[[:cntrl:]]\[//g'

Regards
Steven Sim Kok Leong
Honored Contributor
Solution

Re: Special characaters

Hi,

You can also use strings to filter off non-text chracters including the ctrl chracters ie.

# top -d 1 | strings

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Robin Wakefield
Honored Contributor

Re: Special characaters

Hi Jerome,

Not sure if you realise, but there's a hidden (not in my man pages anyway) -f switch to allow you to dump the output to a file.

Rgds, Robin.
Madhu Sudhan_1
Respected Contributor

Re: Special characaters

Guess you are using vi to search and replace the special characters. If so the trick to look for special characters in vi is s/Cntrl+v+m//g. To replace ^M with nothing.
The same search will fail if you use ^M (which is caret/circumflex/(Shift + 6).
Cntrl+v remains the same and the other charachters keep changing based on your search requirements.

Hope this helps.
-Madhu
Think Positive
Madhu Sudhan_1
Respected Contributor

Re: Special characaters

Take a look at my thread regarding -f option with top.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5ee3f841489fd4118fef0090279cd0f9,00.html

-Madhu
Think Positive