Operating System - HP-UX
1827808 Members
2928 Online
109969 Solutions
New Discussion

Re: convert data file to text or ascii file

 
mw_4
Frequent Advisor

convert data file to text or ascii file

Hi guys..
I have a problem with reading data file..
when I read the file using vi or cat. a few lines and control characters are shown
like "_^He_^Hs" nd "_^Hp_^Hr" etc. I attached that file
how can I convert the file to read it?
Post that solution thanks.
Step by step
4 REPLIES 4
Steven Sim Kok Leong
Honored Contributor

Re: convert data file to text or ascii file

Hi,

If you want to remove special or ctrl characters, you can do any of the following to strip into pure text or ascii:

1) Use strings:

# strings infile > outfile

2) Use col:

# cat infile | col -b > outfile

Hope this helps. Regards.

Steven Sim Kok Leong
A. Clay Stephenson
Acclaimed Contributor

Re: convert data file to text or ascii file

Your best bet is to use od -Ad -t c myfile | pg
to view the file. It will display the printable ASCII and octal values for other characters.

Man od for details.
If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: convert data file to text or ascii file

Hi MW

you may like to use mutilple sed's like I tried these 3 to get o/p.

#cat test | sed -e "1,$ s/\^//g"|sed -e "1,$ s/\;//g"|sed -e "1,$ s/\]//g"

C
console\263Rbonline<\334`Dpts/2192.168.1.170<\333?Jpts/2192.168.1.170ts/3zerg<\204Mdpts/2192.168.1.160K?pts/2211.237.50.246K?pts/2211.237.50.246
\263!Spts/6online\263!8pts/6online..



Manoj Srivastava

Mark Greene_1
Honored Contributor

Re: convert data file to text or ascii file

try this:

tr -d [:cntrl:] new_file

HTH
mark
the future will be a lot like now, only later