we have recently installed RHEL4.4 and when i give the commd
ls -l > tt it prints the file name with some special charactes like
^[[00m1 in the begining of the file name and at the end of the file name. I wanted to use the file names of removing it before taking
the backup and to use in awk script I want to remove the unprintable
characters .
I have tried
sed 's/^[...../p' input file > output file , but the characters varies in their
lenght so unable to remove . kindly guide ..
Why are you using "ls -l" if all you want is the names? Try ls -1.. That will simplify things for you... As for the special characters, get used to "od" Octal Dump.... Look at the hex values... try
ls -1 | od -cx > somefile
Then you can actually see what values are in those "unprintable" columns. Impossible to tell from what you write here because every character set interprets those values differently.... Once you know what the characters really are (in hex) you can come up with a way of eliminating them... Still, I don't know what RHEL is... Is it real unix?
RHEL is Red Hat Enterprise (mumble) something, i.e. Linux.
Maybe it's as simple as "unalias ls". Some distros provide an alias which enables directory coloring, which will output some escape codes to provide text in different colors. If your terminal doesn't understand those escape codes, you would see something like what you describe.
Yes makes sense. Hadn't thought of that. I've got a little project of my own that requires getting rid of escapes like that (simple perl pattern). I wondered what they might be for, now I remember... thanks
$INPTBffr =~ s/[^\x0A\x0D\x20-\x7E]+//g;
Using something like the above to strip binaries, and newlines leaving pure text stream.....