Error free Outputting of Man pages to text

I’ve been writing a script to parse some information from Terminal Man pages, but found that a basic output command produced duplicate letters, and other odd formatting errors.  I couldn’t seem to find any reason for the error, but happened upon the following solution.

Simply putting a col -b command after calling up the man page removed any formatting errors, and gave me a clean block of text to work with.  The col command basically cleans up line feed output, making sure that all the information is in the right order, and doesn’t contain unnecessary information.

So now, to get a sweet bit of Unix command definition into a variable, I simply set the following:

set manPage to (do shell script “man ” & cmd & ” | col -b”)

“cmd” is the variable assigned to whatever command the user wants to input.

Thanks to Erics Sadun over at TUAW for the tip, which you can read in full here.

  1. wozwas posted this
Short URL for this post: http://tmblr.co/Z03dNx9TtBmj