man manual content export to file

Usually when the terminal command exports files, we will use >, >>.

  • > : overwrite mode

  • >> : append mode


➜ echo "hello world" > test2.txt
➜ echo "apple" >> test2.txt

Sometimes, however, export files contain some control symbols.


➜ man grep > test3.txt

➜ vim test3.txt

The export file contains ^H. (^H = Backspace)

How to export normal files?

Use the Linux col command.
The Linux col command is used to filter control characters.

➜ man grep | col -b > test4.txt

➜ vim test4.txt

linux col syntax

 col [-bfhpx] [-l num]

 -b : Do not output any backspaces, printing only the last character written to each column position.  

-f : Forward half line feeds are permitted (``fine'' mode).  Normally characters printed on a half line boundary are printed on the following line.  

-h : Do not output multiple spaces instead of tabs (default).  -l num  Buffer at least num lines in memory.  By default, 128 lines are buffered.  

-p : Force unknown control sequences to be passed through unchanged.  Normally, col will filter out any control sequences from the input other than those recognized and interpreted by itself, which are listed below.  

-x : Output multiple spaces instead of tabs.

Add a Comment

Your email address will not be published. Required fields are marked *