LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1713|回复: 10

我想把man帮助文档重定向输出,结果有很多不太懂的符号

[复制链接]
发表于 2008-3-5 17:56:21 | 显示全部楼层 |阅读模式
命令如此
man awk > 1
用vi查看
本来用 man awk查看的时候显示的是这样
NAME
awk - pattern scanning and processing language

SYNOPSIS
awk [-F ERE][-v assignment] ... program [argument ...]

awk [-F ERE] -f progfile ... [-v assignment] ...[argument ...]

但是输出后, vi 1 成了这样:

^[[1mNAME^[[0m
awk - pattern scanning and processing language

^[[1mSYNOPSIS^[[0m
^[[1mawk [-F ^[[4m^[[22mERE^[[24m^[[1m][-v ^[[4m^[[22massignment^[[24m^[[1m] ... ^[[4m^[[22mprogram^[[24m ^[[1m[^[[4m^[[22margument^[[24m ^[[1m...]^[[0m

^[[1mawk [-F ^[[4m^[[22mERE^[[24m^[[1m] -f ^[[4m^[[22mprogfile^[[24m ^[[1m... [-v ^[[4m^[[22massignment^[[24m^[[1m] ...[^[[4m^[[22margument^[[24m ^[[1m...]^[[0m


我又用了 man awk | col -b > 1

vi 1查看是:
1mNAME0m
awk - pattern scanning and processing language

1mSYNOPSIS0m
1mawk [-F 4m22mERE24m1m][-v 4m22massignment24m1m] ... 4m22mprogram24m 1m[
4m22margument24m 1m...]0m

1mawk [-F 4m22mERE24m1m] -f 4m22mprogfile24m 1m... [-v 4m22massignment24
m1m] ...[4m22margument24m 1m...]0m

这些字符到底是什么呢?
我不知道是什么问题,望高手们给个答案.
发表于 2008-3-5 23:19:17 | 显示全部楼层
怎么我的就没问题?
nile@un:~$ man awk > /tmp/aaa
Reformatting awk(1), please wait...
nile@un:~$ vi /tmp/aaa

MAWK(1)                          USER COMMANDS                         MAWK(1)



NAME
       mawk - pattern scanning and text processing language

SYNOPSIS
       mawk  [-W  option]  [-F value] [-v var=value] [--] ’program text’ [file
       ...]
       mawk [-W option] [-F value] [-v var=value] [-f program-file] [--] [file
       ...]

DESCRIPTION
       mawk  is an interpreter for the AWK Programming Language.  The AWK lan‐
       guage is useful for manipulation of data files, text retrieval and pro‐
       cessing,  and  for prototyping and experimenting with algorithms.  mawk
       is a new awk meaning it implements the AWK language as defined in  Aho,
       Kernighan  and Weinberger, The AWK Programming Language, Addison-Wesley
       Publishing, 1988.  (Hereafter referred to as the AWK book.)  mawk  con‐
       forms  to  the Posix 1003.2 (draft 11.3) definition of the AWK language
       which contains a few features not described in the AWK book,  and  mawk
       provides a small number of extensions.

       An  AWK  program  is  a sequence of pattern {action} pairs and function
       definitions.  Short programs are entered on the  command  line  usually
       enclosed  in ’ ’ to avoid shell interpretation.  Longer programs can be
       read in from a file with the -f option.  Data  input is read  from  the
       list  of files on the command line or from standard input when the list
       is empty.  The input is broken into records as determined by the record
       separator  variable,  RS.  Initially, RS = "\n" and records are synony‐
       mous with lines.  Each record is compared against each pattern  and  if
       it matches, the program text for {action} is executed.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-6 02:08:25 | 显示全部楼层
Post by Akrit;1823526
怎么我的就没问题?
nile@un:~$ man awk > /tmp/aaa
Reformatting awk(1), please wait...
nile@un:~$ vi /tmp/aaa

MAWK(1)                          USER COMMANDS                         MAWK(1)



NAME
       mawk - pattern scanning and text processing language

SYNOPSIS
       mawk  [-W  option]  [-F value] [-v var=value] [--] ’program text’ [file
       ...]
       mawk [-W option] [-F value] [-v var=value] [-f program-file] [--] [file
       ...]

DESCRIPTION
       mawk  is an interpreter for the AWK Programming Language.  The AWK lan‐
       guage is useful for manipulation of data files, text retrieval and pro‐
       cessing,  and  for prototyping and experimenting with algorithms.  mawk
       is a new awk meaning it implements the AWK language as defined in  Aho,
       Kernighan  and Weinberger, The AWK Programming Language, Addison-Wesley
       Publishing, 1988.  (Hereafter referred to as the AWK book.)  mawk  con‐
       forms  to  the Posix 1003.2 (draft 11.3) definition of the AWK language
       which contains a few features not described in the AWK book,  and  mawk
       provides a small number of extensions.

       An  AWK  program  is  a sequence of pattern {action} pairs and function
       definitions.  Short programs are entered on the  command  line  usually
       enclosed  in ’ ’ to avoid shell interpretation.  Longer programs can be
       read in from a file with the -f option.  Data  input is read  from  the
       list  of files on the command line or from standard input when the list
       is empty.  The input is broken into records as determined by the record
       separator  variable,  RS.  Initially, RS = "\n" and records are synony‐
       mous with lines.  Each record is compared against each pattern  and  if
       it matches, the program text for {action} is executed.
这个我就不知道了...
我用的 Mandriva2008.0
你呢?
回复 支持 反对

使用道具 举报

发表于 2008-3-6 09:05:54 | 显示全部楼层
关于楼主的问题, 导出的东西用 less 看就没问题了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-6 13:55:13 | 显示全部楼层
Post by remote fish;1823606
关于楼主的问题, 导出的东西用 less 看就没问题了
用less 还是不行
bash-3.2$ man awk > /tmp/aaa
bash-3.2$ less /tmp/aaa

ESC[1mNAMEESC[0m
       awk - pattern scanning and processing language

ESC[1mSYNOPSISESC[0m
       ESC[1mawk [-F ESC[4mESC[22mEREESC[24mESC[1m][-v ESC[4mESC[22massignment
ESC[24mESC[1m] ... ESC[4mESC[22mprogramESC[24m ESC[1m[ESC[4mESC[22margumentESC[24m ESC[1m...]ESC[0m

       ESC[1mawk [-F ESC[4mESC[22mEREESC[24mESC[1m] -f ESC[4mESC[22mprogfileESC[24m ESC[1m...  [-v ESC[4mESC[22massignmentESC[24mESC[1m] ...[ESC[4mESC[22margumentESC[24m ESC[1m...]ESC[0m


还多了 ESC 这些东西

不过我按"q"退出 man 的时候,有个提示
“/usr/bin/iconv: 由于写入输出时出现的问题转换停止”

是不是本身的输入输出问题呢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-6 13:55:13 | 显示全部楼层
Post by remote fish;1823606
关于楼主的问题, 导出的东西用 less 看就没问题了
用less 还是不行
bash-3.2$ man awk > /tmp/aaa
bash-3.2$ less /tmp/aaa

ESC[1mNAMEESC[0m
       awk - pattern scanning and processing language

ESC[1mSYNOPSISESC[0m
       ESC[1mawk [-F ESC[4mESC[22mEREESC[24mESC[1m][-v ESC[4mESC[22massignment
ESC[24mESC[1m] ... ESC[4mESC[22mprogramESC[24m ESC[1m[ESC[4mESC[22margumentESC[24m ESC[1m...]ESC[0m

       ESC[1mawk [-F ESC[4mESC[22mEREESC[24mESC[1m] -f ESC[4mESC[22mprogfileESC[24m ESC[1m...  [-v ESC[4mESC[22massignmentESC[24mESC[1m] ...[ESC[4mESC[22margumentESC[24m ESC[1m...]ESC[0m


还多了 ESC 这些东西

不过我按"q"退出 man 的时候,有个提示
“/usr/bin/iconv: 由于写入输出时出现的问题转换停止”

是不是本身的输入输出问题呢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-6 13:57:48 | 显示全部楼层
sorry, 不小心回复按多了..........
怎么删除多余的帖子呢?
回复 支持 反对

使用道具 举报

发表于 2008-3-6 17:05:55 | 显示全部楼层
man awk | col -b > 1
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-7 15:50:26 | 显示全部楼层
Post by ly5066113;1823801
man awk | col -b > 1
我试验过哈,第一个帖子就写了的
回复 支持 反对

使用道具 举报

发表于 2008-3-7 16:44:07 | 显示全部楼层
Post by yalewhd;1824136
我试验过哈,第一个帖子就写了的


Sorry,没看清楚。原因可以参考:

原帖由 ivhb 于 2008-1-25 21:48 发表
^H其实就是退格。
在一般的打印格式里面,比如行式打印。
打印到 A^HA,会做什么动作呢? 先打印A,打印头挪到下一个位置。遇到了^H(退格),又回到了A的位置,再打印一遍A,在打印纸上就能看到这个A明显得比其他字符黑粗。实现了黑体打印的效果。
实际上你仔细观察一下文件,很有规律的,每个出现^H的地方,对应的就是直接man的高亮部分。
而且,^H两边的字符肯定是一样的。
根据这个,你可以制作自己的高亮效果。
选择要高亮的文本部分。然后vi/sed   s/./&^H&/g 保存后,再more这个文件,看看什么效果?
col -b就是用来把X^HX部分,合并成X的过程。如果用C来写,将是非常简单的事情。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表