Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

neesthan

macrumors newbie
Original poster
Dec 3, 2011
5
0
Hello. I try to save some man pages on my Snow Leopard. I do it the following way:
Code:
man cp > man_cp.txt
Then when I try to open it in Terminal like this
Code:
less man_cp.txt
it looks fine. But when I try to open it in TextEdit, for instance, the text looks very strange - some characters are doubled like this:
CP(1) BSD General Commands Manual CP(1)

NNAAMMEE
ccpp -- copy files

SSYYNNOOPPSSIISS
ccpp [--RR [--HH | --LL | --PP]] [--ffii | --nn] [--aappvvXX] _s_o_u_r_c_e___f_i_l_e _t_a_r_g_e_t___f_i_l_e
ccpp [--RR [--HH | --LL | --PP]] [--ffii | --nn] [--aappvvXX] _s_o_u_r_c_e___f_i_l_e _._._.
_t_a_r_g_e_t___d_i_r_e_c_t_o_r_y

DDEESSCCRRIIPPTTIIOONN
In the first synopsis form, the ccpp utility copies the contents of the
_s_o_u_r_c_e___f_i_l_e to the _t_a_r_g_e_t___f_i_l_e. In the second synopsis form, the con-
tents of each named _s_o_u_r_c_e___f_i_l_e is copied to the destination
_t_a_r_g_e_t___d_i_r_e_c_t_o_r_y. The names of the files themselves are not changed. If
ccpp detects an attempt to copy a file to itself, the copy will fail.
If I try to print it out on a printer it also looks wrong.
What's the reason?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
The default output from man is formatted for a simple terminal or printer using backspaces and overstrikes. You can't see backspaces and overstrikes in TextEdit.app.

Everywhere you see a doubled character, there's a backspace between them. This represents bold. Where you see _ followed by a letter, that's underlined, and there's a backspace between them, too.

If your goal is to print man pages on a printer, I suggest getting Bwana, opening the man page in your web browser, and printing it from there.

If your goal is something else, please explain exactly what it is.
 

neesthan

macrumors newbie
Original poster
Dec 3, 2011
5
0
Thanks, chown33, for your exhaustive explanation why the text looks that way.
My goal was just to print it out on paper for reference. I have just got a suggestion from another forum - using -t option:
Code:
man -t cp > man_cp
It will save man_cp as a PostScript file which then can be viewed and printed through Preview.app, for instance.
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
Thanks. I just took the cp command as an example. Actually I needed man pages to exiv2 (metadata manipulation for jpeg and other formats) which was installed through MacPorts. This is not a standart program and I am not sure it will be on the site you've mentioned.
Code:
man exiv2 | col -b | open -f
... will do what you want.
Replace "exiv2" with the name of the program in question. That will open the manual in TextEdit, formatted neatly.

Tip from here: http://www.tuaw.com/2007/04/19/terminal-tip-output-man-pages-as-plain-text-with-col/
 

neesthan

macrumors newbie
Original poster
Dec 3, 2011
5
0
Well, I think this way is even better because you don't need to save the file. The only thing: if one wants to open a manual in a specific application, for instance, TextWrangler, one need to add -a and the path to that application:
Code:
man exiv2 | col -b | open -f -a /Applications/TextWrangler.app

Thanks to everybody!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.