On Tue, 26 Dec 2000 18:59:46 Bret Hughes wrote:
>Bob Hartung wrote:
>>   There are times that I would like to print some of the man
>> pages to read through when away from the computer.  Is there
>> a way to capture a particular man page to a text file that
>> will have proper formatting?
>
>Do you mean other than redirect the output?  I use man command |lpr and
>man command > filename all the time

"man command > file" creates a text file that looks okay with "less" but
includes carriage returns that may not be handled correctly by other tools
(take a look at it in vi). Another possibility is a PDF file. Here's a short
script that does the trick:

#!/bin/sh
#
# man2pdf: Converts a manpage to PDF format.
#
# Requires ps2pdf utility.

# Make sure the required argument is present.
if [ "$1" = "" ]; then
  echo "Usage: `basename $0` [section] commandname"
  exit
fi

# Assign a section variable if specified on the command line
if [ -n "$2" ]; then
  command="$2"
  section="$1"
else
  command="$1"
  section=""
fi

# Convert to Postscript
man -t $section $command > $command.ps

# Convert to PDF
ps2pdf $command.ps

# Check for success
if [ -f $command.pdf ]; then
  echo "Created $command.pdf" 
else
  echo '$0 failed to create $1.pdf.'
fi

# Remove intermediate Postscript file
rm $command.ps
# end of script



Tony
-- 
Anthony E. Greene <[EMAIL PROTECTED]> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26  C484 A42A 60DD 6C94 239D
Chat:  AOL/Yahoo: TonyG05    ICQ: 91183266
Linux. The choice of a GNU Generation. <http://www.linux.org/>



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to