Sponsored Content
Top Forums Shell Programming and Scripting Non-ASCII char prevents conversion of manpage to plain text Post 302460092 by LessNux on Wednesday 6th of October 2010 04:36:10 AM
Old 10-06-2010
I have found a solution. The configuration file /usr/lib/man.conf needs to be modified as I will explain below.

The man command internally calls nroff and/or groff. It also calls geqn or eqn. The file "man.conf" contains some lines that define how man will call nroff, groff, geqn and/or eqn with what options. The "-Tlatin1" option in man.conf allows man to output non-ASCII characters (0x80 through 0xFF). By replacing "-Tlatin1" with "-Tascii, man no longer outputs non-ASCII characters, and man automatically converts non-ASCII characters into ASCII equivalents such as "(C)" for the copyright character.

Before the modification:
NROFF /usr/bin/nroff -Tlatin1 -mandoc
NEQN /usr/bin/geqn -Tlatin1

After the modification:
NROFF /usr/bin/nroff -Tascii -mandoc
NEQN /usr/bin/geqn -Tascii

After the modification to "man.conf", the following command line successfully exports manual pages to plain text files.

man CommandName | col -bx > CommandName.txt



By the way, piping to "col" is necessary. Without "col", the resultant text would not be plain. The direct output from man is not plain text. The fact that the output from man to stdout (terminal) contains bold-face letters and underscored letters suggests that the text is not plain.

In fact, let the output from man be redirected to a file without "col" as shown below, and open the file with GUI-based text editor (e.g., TextEdit on Mac OS X, KWrite on KDE-equipped Linux, NotePad on Windows).

man ln > ln.txt

Then, you will see a bunch of illegible strings like the following, proving that the output is not plain text.

N[]NA[]AM[]ME[]E
S[]SY[]YN[]NO[]OP[]PS[]SI[]IS[]S
D[]DE[]ES[]SC[]CR[]RI[]IP[]PT[]TI[]IO[]ON[]N

The man command outputs lots of backspace characters, which are illegal in plain text. On GUI-based text editors, you will see square characters in place of backspace characters. Since it is difficult to display square characters on this web page, I used [] to represent a square character.


The "col" command converts the above illegible strings into the following plain text.

NAME
SYNOPSIS
DESCRIPTION

Thus, "col" is absolutely necessary to obtain plain text from "man".


I thank cjcox and Franklin52 for trying to help me. I apologize cjcox for mistaking his generous help for a joke.

Last edited by LessNux; 10-06-2010 at 05:51 AM..
This User Gave Thanks to LessNux For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ASCII to char convertion

I am writing the script to encrypt and decrypt content of the text file. How can I convert ASCII to characters and backward? I need it for Bourne shell script. Thanks::confused: (3 Replies)
Discussion started by: woody
3 Replies

2. Shell Programming and Scripting

ascii conversion

after converting my ebcidic file to ascii i get the following output 2097152+0 records in 1797345+1 records out Why is there a difference in number of records. Is the converson chopping off any records. All i am doing is just a conversion using the following script dd if=xaa cbs=152 ... (0 Replies)
Discussion started by: rintingtong
0 Replies

3. Shell Programming and Scripting

help needed with ASCII conversion

I have a file say "codefile" here ,contains data like this Hi! How are you? I need to covert this data into stram of equivalant ASCII values I wrote follwoing script. #!/bin/bash while read -n1 char do printf "%d" \'$char done < codefile this gives me output ... (4 Replies)
Discussion started by: sunilmenhdiratt
4 Replies

4. Shell Programming and Scripting

need help with ascii to decimal conversion

Hi, Can anyone please help me ascci to decimal conversion in bash I have a file which contains stream of numbers like this,these are ascci values 729711810132973278105991013268971213233 I want to covert it to its actual value like upper code's decimal is "Have a Nice Day!" ... (15 Replies)
Discussion started by: sunilmenhdiratt
15 Replies

5. UNIX for Dummies Questions & Answers

Conversion from EBCDIC to ASCII

when i try to convert a mainframe EBCDIC file to ASCII ,i dont see correct file this is the source file ... (3 Replies)
Discussion started by: venkatvelpula
3 Replies

6. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

7. Shell Programming and Scripting

ASCII to UTF-8 conversion

I Am trying to change the file encoding from ASCII to UTF-8 using below command iconv -f ASCII -t UTF-8 <input_file> > <output_file> But the output_file is not actually in UTF-8 format. If I use the file command to check the file encoding it still says ASCII. While converting am not... (5 Replies)
Discussion started by: Sriranga
5 Replies

8. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies

9. UNIX for Advanced & Expert Users

EBCDIC to ASCII conversion

Hi, I have a input file which is EBCIDIC and it has packed decimals. Can anyone help me to convert EBCIDIC file to ASCII(Need to convert even Packed decimal values also to normal format). Thanks swapna (12 Replies)
Discussion started by: swapna_1990
12 Replies

10. UNIX for Advanced & Expert Users

EBCDIC to ASCII conversion

Hi, We have a mainframe file which is in EBCDIC format.We dont have direct access to mainframe ,client has provided us the mainframe file.The mainframe file is containing pact data(COMP1 ,COMP2 etc) which are unreadble.Can anyone suggest me how to convert this kind of ebcdic file to ascii... (11 Replies)
Discussion started by: swapna_1990
11 Replies
MAN(1)							      General Commands Manual							    MAN(1)

NAME
man, lookman - print or find pages of this manual SYNOPSIS
man [ option ... ] [ section ... ] title ... lookman key ... DESCRIPTION
Man locates and prints pages of this manual named title in the specified sections. Title is given in lower case. Each section is a num- ber; pages marked (2S), for example, belong to chapter 2. If no section is specified, pages in all sections are printed. Any name from the NAME section at the top of the page will serve as a title. The options are: -p Run proof(1) on the specified man pages. -t Run troff and send its output to standard output. -n (Default) Print the pages on the standard output using nroff. Lookman prints the names of all manual sections that contain all of the key words given on the command line. FILES
/sys/man/?/* troff source for manual; this page is /sys/man/1/man /sys/man/?/INDEX indices searched to find pages corresponding to titles /sys/lib/man/secindex command to make an index for a given section /sys/lib/man/lookman/index index for lookman SOURCE
/rc/bin/man /rc/bin/lookman SEE ALSO
proof(1) BUGS
The manual was intended to be typeset; some detail is sacrificed on text terminals. There is no automatic mechanism to keep the indices up to date. Except for special cases, it doesn't recognize things that should be run through tbl and/or eqn. MAN(1)
All times are GMT -4. The time now is 02:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy