Redirected text file has weird control chars.

Redirected text file has weird control chars.

Post by David Morris Jacks » Sun, 27 Feb 1994 03:43:39



When I do this:  

man xdm > textfile  (replace 'xdm' with any unix man pg. entry)

I get weird control characters in textfile. I'm using a vt100
terminal telnet'ed to a UNIX system (and using csh). How do I
get "just" a text file?

If I printed this file on a postscript printer, would these
characters be interpreted as underlines and bold-characters?

Thanks.

--
David M. Jackson
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!gt1801a

 
 
 

Redirected text file has weird control chars.

Post by Stryd » Tue, 01 Mar 1994 10:18:27



Quote:>When I do this:  
>man xdm > textfile  (replace 'xdm' with any unix man pg. entry)
>I get weird control characters in textfile. I'm using a vt100
>terminal telnet'ed to a UNIX system (and using csh). How do I
>get "just" a text file?
>If I printed this file on a postscript printer, would these
>characters be interpreted as underlines and bold-characters?
>Thanks.

I'll take a stab at this one.  The output of the man command includes codes
for bolding, using <ctrl-h> to backspace and then repeating the character,
as well as <ctrl-h> to backspace and then underline the character on your
screen.  When you redirect this stuff to a file, it doesn't act right.

I put together a little C program that you can pipe your man information
through in order to take out underscores as well as <ctrl-h>s and the
characters that follow...

#include <stdio.h>

main()
{
        int character;

        while (1)
        {
                switch(character = getchar())
                {
                        case EOF:
                                break;
                        case '_':
                                getchar();
                                break;
                        case '\x08':
                                getchar();
                                break;
                        default:
                                putchar(character);
                                break;
                };

                if (character == EOF)
                {
                        exit(0);
                }
        }

Quote:}

Compile this guy using "cc no_ctrl_h.c".  Then rename the excutable a.out
to whatever you want - "clean" is pretty good.  Then pipe your stuff through
it like so...

                   man xadm | clean > xadm.clean

This works on my COHERENT system, but I can't tell on this Sun OS, 'cause
the man pages seem to redirect clean already.

>--
>David M. Jackson
>Georgia Institute of Technology, Atlanta Georgia, 30332
>uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!gt1801a



 
 
 

Redirected text file has weird control chars.

Post by B.N.Blackmo » Tue, 01 Mar 1994 18:59:06




>> When I do this:

>> man xdm > textfile  (replace 'xdm' with any unix man pg. entry)

>> I get weird control characters in textfile. I'm using a vt100
>> terminal telnet'ed to a UNIX system (and using csh). How do I get
>> "just" a text file?

>> If I printed this file on a postscript printer, would these
>> characters be interpreted as underlines and bold-characters?

>> Thanks.
> I'll take a stab at this one.  The output of the man command
> includes codes for bolding, using <ctrl-h> to backspace and then
> repeating the character,  as well as <ctrl-h> to backspace and
> then underline the character on your screen.  When you redirect
> this stuff to a file, it doesn't act right.
> I put together a little C program....

[stuff deleted]

You don't need to go overboard an write a C program to do this, somebody
has already done it.

So the in great tradition of being too lazy to write it yourself try

man xdm|col -b > filename

At least it works on SUNOS 4.*
--
print "Just another Perl hacker";

Brian Blackmore, Darwin College, The University of Kent at Canterbury, UK.

 
 
 

Redirected text file has weird control chars.

Post by Part » Wed, 02 Mar 1994 00:12:35



Quote:> When I do this:  
> man xdm > textfile  (replace 'xdm' with any unix man pg. entry)
> I get weird control characters in textfile. I'm using a vt100
> terminal telnet'ed to a UNIX system (and using csh). How do I
> get "just" a text file?

  man xdm | col -bx > textfile

(This should be in the FAQ...)

Quote:> If I printed this file on a postscript printer, would these
> characters be interpreted as underlines and bold-characters?

No, you would need a separate troff-postscript run to
produce a really beautiful postscript printout.

--

EDV-Zentrum, Universitaet fuer Bodenkultur
Nussdorfer Laende 11                      Please correct me if I'm wrong!
A-1190 Wien, Austria (Europe)             Make love, not flame wars.  :-)

 
 
 

1. get rid of control char in text file

Hi,

I have a large number of C source files, each with a control char '\032' sticking at the end of the file. Never mind how I got it.
The nature of the control char:
1)  when I compile the source code, 'cc' complains:
     No new-line char at end-of-file
     Unknown control character \032
2)  use vi to look at the file, last line appears to be '^Z'
3)  use cat, last line does not appear.

I tried         tr "[^Z]" "[\012]" < old > new
     and        tr "[\032]" "[\012]" < old > new
 to replace it with new line char, and I got "bad string" complaints

Obviously I can delete the last line with vi manually, but it looks silly.

Any suggestion of a shell script will be highly appreciated ?

J. Zhou
--

=============================================================
  http://irc.leeds.ac.uk/~phyjz/jianping.html
                     |  J. Zhou  |

=============================================================

2. USB Mouse

3. EOF: text or control char

4. samba connectivity with WIN98

5. How do I delete files w/control char embedded in file name?

6. CDE

7. : Weird ">" redirect behavior vs. ">>" redirect behavior

8. Problem with kernel compile

9. \0 char embedded in text file

10. Removing control chars from file ???

11. how do i use sed to remove carriage control chars. from file

12. HELP: How to redirect stdout and stderr to a text file.

13. How to redirect man page to plain text file?