^H characters appear when opening text file using vi - RHEL


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ^H characters appear when opening text file using vi - RHEL
# 1  
Old 06-10-2013
^H characters appear when opening text file using vi - RHEL

Version Info:

Code:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
$
$ uname -a
Linux stryker138 2.6.18-308.13.1.el5 #1 SMP Thu Jul 26 05:45:09 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

I redirected manpage of ksh command's output to a text file as shown below
Code:
$ pwd
/home/oracle/purge/stage1
$ man ksh >kshManPage.txt
$
$ vi kshManPage.txt

When I try to open using vi, the file seems to filed with ^H. It looked like below

Code:
$ vi kshManPage.txt
KSH(1)                                                                  KSH(1)



N^HNA^HAM^HME^HE
       ksh,  rksh,  pfksh  - KornShell, a standard/restricted command and pro-
       gramming language

S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS
       k^Hks^Hsh^Hh [ ±^H±a^Hab^Hbc^Hce^Hef^Hfh^Hhi^Hik^Hkn^Hno^Hop^Hpr^Hrs^Hst^Htu^Huv^Hvx^HxB^HBC^HCD^HDP^HP ] [ -^H-R^HR file ] [ ±^H±o^Ho option ] ... [  -^H-  ]  [   arg ... ]

D^HDE^HES^HSC^HCR^HRI^HIP^HPT^HTI^HIO^HON^HN
       _^HK_^Hs_^Hh  is  a command and programming language that executes commands read
       from a terminal or a file.  _^HR_^Hk_^Hs_^Hh is a restricted version of the command
       interpreter  _^Hk_^Hs_^Hh;  it is used to set up login names and execution envi-
       ronments whose capabilities are more controlled than those of the stan-
       dard  shell.   _^HR_^Hp_^Hf_^Hk_^Hs_^Hh  is a profile shell version of the command inter-
       preter _^Hk_^Hs_^Hh; it is used to to execute commands with the attributes spec-
       ified by the userâs profiles (see _^Hp_^Hf_^He_^Hx_^He_^Hc(1)).  See _^HI_^Hn_^Hv_^Ho_^Hc_^Ha_^Ht_^Hi_^Ho_^Hn below for

But ^H characters don't appear when I open the file using cat


Code:
$ cat kshManPage.txt
KSH(1)                                                                  KSH(1)



NAME
       ksh,  rksh,  pfksh  - KornShell, a standard/restricted command and pro-
       gramming language

SYNOPSIS
       ksh [ ±abcefhiknoprstuvxBCDP ] [ -R file ] [ ±o option ] ... [  -  ]  [
       arg ... ]

DESCRIPTION
       Ksh  is  a command and programming language that executes commands read
       from a terminal or a file.  Rksh is a restricted version of the command
       interpreter  ksh;  it is used to set up login names and execution envi-
       ronments whose capabilities are more controlled than those of the stan-
       dard  shell.   Rpfksh  is a profile shell version of the command inter-
       preter ksh; it is used to to execute commands with the attributes spec-
       ified by the userâs profiles (see pfexec(1)).  See Invocation below for
       the meaning of arguments to the shell.
.
.
.
<output snipped>

Related info:

Just discovered that the vi used in RHEL is actually VIM !

Code:
$ which vi
/bin/vi
$
$ man vi
VIM(1)                                                                  VIM(1)

NAME
       vim - Vi IMproved, a programmers text editor

SYNOPSIS
       vim [options] [file ..]
       vim [options] -
       vim [options] -t tag
       vim [options] -q [errorfile]
.
.
.
DESCRIPTION
       Vim  is  a  text  editor that is upwards compatible to Vi.  It can be used to edit all kinds of plain text.  It is especially useful for editing
       programs.
.
.

<output snipped>

Any idea why ^H characters are appearing with vi and is there any way to fix it?
# 2  
Old 06-10-2013
A man page is not just a simple text document. When you issue man <something> you will notice that bold printing and maybe other formatting appears. This is done by "compiling" man (source) pages with a text formatting utility: troff, which basically inserts these formatting codes into the text.

If you have gotten your man page by a command like:

Code:
man ksh > /path/to/some/file

then these formatting codes are still in it.
Code:
cat

just doesn't display them. Use a utility like deroff to remove the formatting and markup.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 06-10-2013
I usually use the following if I find the need to convert a man page to a text file:

Code:
man ksh | col -b > kshManPage.txt

# 4  
Old 06-10-2013
In addition to what bakunin and in2nix4life have said, using x\bx\bx (where x is any printing character and \b is a backspace character) is a remnant of the days before CRT terminals. On a hardcopy device, that sequence literally printed the character 3 times in (almost) the same position (making it appear as bold text). Some CRT displays also recognized this sequence and highlighted characters presented this way. Some line printers also printed lines containing backspaces multiple times such that each overstruck character was printed in the appropriate position as many times as it appeared in the line (again producing bold text because hard copy devices were never accurate enough to double or triple print a character at exactly the same position).

Another common sequence is _\bx which produces underlined text on hardcopy output devices and on soft copy devices that recognize the sequence to produce underlined text.

Back in the early days, nroff was used for character addressable device output and troff was use to produce output for typesetting hardware. Later, troff device tables allowed it to be used with any type of output device. Historically, the col utility was used to get rid of several nroff artifacts that made it hard for humans to read the text files containing the overstrikes on a device that showed all of the characters in a line without performing overstrike processing (such as on a CRT when using vi to view the contents of the file). The col utility could also be used to convert tabs to sequences of spaces and vice versa, and also had options for dealing with half-line motions (that nroff used to display subscripts and superscipts on terminals and printers like the DASI 300s daisy wheel printers and terminals). Some later *roff implementations provided deroff in addition to or instead of col; but most systems that have an nroff utility also have a col utility (look for man pages for these utilities to determine the choices you have on your system).

Note also that without options, the cat utility doesn't do anything to get rid of overstrikes; it just copies data to the output device and the overstrikes and when an output device handles overstrikes by displaying the last character "printed" in a given output position, the overstrikes become invisible.

Thus endeth this morning's ancient history lesson on overstriking. Smilie
These 2 Users Gave Thanks to Don Cragun For This Post:
# 5  
Old 06-10-2013
You are just a couple of clicks away:-

^H
This User Gave Thanks to wisecracker For This Post:
# 6  
Old 06-11-2013
Thank you Bankunin, Don, in2nix4life, wisecracker for the explanations/solutions.

I didn't have deroff utility installed in my RHEL server.

in2nix4life solution using col function worked for me.
# 7  
Old 06-11-2013
Do you have catman command?
do a man of catman...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove all junk characters from a text file

I am using flatfile, in that flat file we are getting the junk chars 1)I21001f<82>^Me<85>!h49 Service Charge 2) I21001f‚ e...!h49 Service Charge please tell me how to remove all junk chars in unix scripts. (1 Reply)
Discussion started by: Talari
1 Replies

2. Red Hat

How to display Chinese and Japanese Characters on Rhel 6?

Hello, I'm trying to figure out how to display Chinese and Japanese Characters on my RHEL 6 Console. There is no more "bogl-bterm" for RHEL6, that is not supported anymore. Is there any way that I could display them? Thank you. (2 Replies)
Discussion started by: pjeedu2247
2 Replies

3. Shell Programming and Scripting

Check if the text file has more than 2 characters

Guys, I know that the below command will cut the 13th field from test.txt file awk -F"|" '{print $13}' test.txt The answer would be, CA CN Ohio If we see the 3 rd one, it has more than 2 characters. So i wanted to check this in if condition and i want to get the output if the 13th... (4 Replies)
Discussion started by: AraR87
4 Replies

4. Shell Programming and Scripting

Counting 2 characters with into 2 categories from a text file

I have a tab delimited file of the following format 2 L a 2 G b 2 L c 2 G a 3 G a 3 G b 3 L c 4 L a 4 G a 4 G b 4 L c 4 G a .. ... I want to count the number of G's and L's with in the first column and the third column/categories such that I would get an output file: (6 Replies)
Discussion started by: Lucky Ali
6 Replies

5. Red Hat

Does RHEL 5 provide a command to collect RHEL system log in single compress file?

Hi, I heard a command that can collect all RHEL 5 log in a single compress file before I forget. Does any body know...What the command is ? Thanks. (4 Replies)
Discussion started by: nnnnnnine
4 Replies

6. UNIX for Dummies Questions & Answers

Any way to get rid of ^M characters in a text file using pr?

When I use vi to see what's in the file I get this: int add1(int x) {^M return x + 1;^M} ^Mint subtract1(int x) {^M return x - 1;^M} ^Mint double_it(int x) {^M return x * 2;^M} ^Mint halve_it(int x) {^Mreturn x / 2;^M} ^Mint main() {^M int myint;^M int result;^M ... (2 Replies)
Discussion started by: Nonito84
2 Replies

7. UNIX for Dummies Questions & Answers

Help with deleting characters from text file

I have a text file that looks like this: I want to delete the last character of first column in all rows so that my output looks like this: Thanks a lot! (1 Reply)
Discussion started by: evelibertine
1 Replies

8. Shell Programming and Scripting

Read text from a file between two characters..

I have a requirement where i have to read from a .sh file a text lying bet characters like 'SELECT' & ';'...Please help me out in this. I am new to shell scripting. (2 Replies)
Discussion started by: goutam_igate
2 Replies

9. UNIX for Dummies Questions & Answers

Urgent help needed to delete some text without opening the file in unix

Hi To delete some text in 2 files in line1 ( not complete line) in unix without opening the files. For example: source file is like this <?xml version="1.0"... (5 Replies)
Discussion started by: pyaranoid
5 Replies

10. Shell Programming and Scripting

How to delete a particular text without opening the file.

Hi, Could someone tell me how to delete a particular text inside an existing file without opening the file? e.g. I have a text file called mytext.txt which contains three lines of text below and I want to delete “ ;” and delete the second line “b ;” including the carriage return. a ; b ; c ;... (12 Replies)
Discussion started by: stevefox
12 Replies
Login or Register to Ask a Question