免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1535 | 回复: 0
打印 上一主题 下一主题

cat ,more, Less区别 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-26 13:34 |只看该作者 |倒序浏览
使用cat more less都可以查看文本内容,但是它们三者有什么区别呢?
more和less的功能完全重复吗?
以下是我个人的总结,欢迎大家一起来分享
cat        连续显示、查看文件内容
more        分页查看文件内容
less        分页可控制查看文件内容
通俗点说:
cat一次性把文件内容全部显示出来,管你看不看得清,显示完了cat命令就返回了,不能进行交互式操作,适合察看内容短小、不超过一屏的文件;
more比cat强大一点,支持分页显示,你可以ctrl+B ctrl+F .....上下滚屏,但是不支持像shift+G(跳到文件尾)这种操作;
less比more更强大一点,支持各种命令,随便翻页、跳转、查找.....想怎么看,就怎么看,爱怎么看,就怎么看。
附less的帮助内容
  1.                    SUMMARY OF LESS COMMANDS
  2.       Commands marked with * may be preceded by a number, N.
  3.       Notes in parentheses indicate the behavior if N is given.
  4.   h  H                 Display this help.
  5.   q  :q  Q  :Q  ZZ     Exit.
  6. ---------------------------------------------------------------------------
  7.                            MOVING
  8.   e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
  9.   y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
  10.   f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
  11.   b  ^B  ESC-v      *  Backward one window (or N lines).
  12.   z                 *  Forward  one window (and set window to N).
  13.   w                 *  Backward one window (and set window to N).
  14.   ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
  15.   d  ^D             *  Forward  one half-window (and set half-window to N).
  16.   u  ^U             *  Backward one half-window (and set half-window to N).
  17.   ESC-)  RightArrow *  Left  one half screen width (or N positions).
  18.   ESC-(  LeftArrow  *  Right one half screen width (or N positions).
  19.   F                    Forward forever; like "tail -f".
  20.   r  ^R  ^L            Repaint screen.
  21.   R                    Repaint screen, discarding buffered input.
  22.         ---------------------------------------------------
  23.         Default "window" is the screen height.
  24.         Default "half-window" is half of the screen height.
  25. ---------------------------------------------------------------------------
  26.                           SEARCHING
  27.   /pattern          *  Search forward for (N-th) matching line.
  28.   ?pattern          *  Search backward for (N-th) matching line.
  29.   n                 *  Repeat previous search (for N-th occurrence).
  30.   N                 *  Repeat previous search in reverse direction.
  31.   ESC-n             *  Repeat previous search, spanning files.
  32.   ESC-N             *  Repeat previous search, reverse dir. & spanning files.
  33.   ESC-u                Undo (toggle) search highlighting.
  34.         ---------------------------------------------------
  35.         Search patterns may be modified by one or more of:
  36.         ^N or !  Search for NON-matching lines.
  37.         ^E or *  Search multiple files (pass thru END OF FILE).
  38.         ^F or @  Start search at FIRST file (for /) or last file (for ?).
  39.         ^K       Highlight matches, but don't move (KEEP position).
  40.         ^R       Don't use REGULAR EXPRESSIONS.
  41. ---------------------------------------------------------------------------
  42.                            JUMPING
  43.   g    ESC->       *  Go to last line in file (or line N).
  44.   p  %              *  Go to beginning of file (or N percent into file).
  45.   t                 *  Go to the (N-th) next tag.
  46.   T                 *  Go to the (N-th) previous tag.
  47.   {  (  [           *  Find close bracket } ) ].
  48.   }  )  ]           *  Find open bracket { ( [.
  49.   ESC-^F    *  Find close bracket .
  50.   ESC-^B    *  Find open bracket  
  51.         ---------------------------------------------------
  52.         Each "find close bracket" command goes forward to the close bracket
  53.           matching the (N-th) open bracket in the top line.
  54.         Each "find open bracket" command goes backward to the open bracket
  55.           matching the (N-th) close bracket in the bottom line.
  56.   m            Mark the current position with .
  57.   '            Go to a previously marked position.
  58.   ''                   Go to the previous position.
  59.   ^X^X                 Same as '.
  60.         ---------------------------------------------------
  61.         A mark is any upper-case or lower-case letter.
  62.         Certain marks are predefined:
  63.              ^  means  beginning of the file
  64.              $  means  end of the file
  65. ---------------------------------------------------------------------------
  66.                         CHANGING FILES
  67.   :e [file]            Examine a new file.
  68.   ^X^V                 Same as :e.
  69.   :n                *  Examine the (N-th) next file from the command line.
  70.   :p                *  Examine the (N-th) previous file from the command line.
  71.   :x                *  Examine the first (or N-th) file from the command line.
  72.   :d                   Delete the current file from the command line list.
  73.   =  ^G  :f            Print current file name.
  74. ---------------------------------------------------------------------------
  75.                     MISCELLANEOUS COMMANDS
  76.   -              Toggle a command line option [see OPTIONS below].
  77.   --             Toggle a command line option, by name.
  78.   _              Display the setting of a command line option.
  79.   __             Display the setting of an option, by name.
  80.   +cmd                 Execute the less cmd each time a new file is examined.
  81.   !command             Execute the shell command with $SHELL.
  82.   |Xcommand            Pipe file between current pos & mark X to shell command.
  83.   v                    Edit the current file with $VISUAL or $EDITOR.
  84.   V                    Print version number of "less".
  85. ---------------------------------------------------------------------------
  86.                            OPTIONS
  87.         Most options may be changed either on the command line,
  88.         or from within less by using the - or -- command.
  89.         Options may be given in one of two forms: either a single
  90.         character preceded by a -, or a name preceeded by --.
  91.   -?  ........  --help
  92.                   Display help (from command line).
  93.   -a  ........  --search-skip-screen
  94.                   Forward search skips current screen.
  95.   -b [N]  ....  --buffers=[N]
  96.                   Number of buffers.
  97.   -B  ........  --auto-buffers
  98.                   Don't automatically allocate buffers for pipes.
  99.   -c  -C  ....  --clear-screen  --CLEAR-SCREEN
  100.                   Repaint by scrolling/clearing.
  101.   -d  ........  --dumb
  102.                   Dumb terminal.
  103.   -D [xn.n]  .  --color=xn.n
  104.                   Set screen colors. (MS-DOS only)
  105.   -e  -E  ....  --quit-at-eof  --QUIT-AT-EOF
  106.                   Quit at end of file.
  107.   -f  ........  --force
  108.                   Force open non-regular files.
  109.   -F  ........  --quit-if-one-screen
  110.                   Quit if entire file fits on first screen.
  111.   -g  ........  --hilite-search
  112.                   Highlight only last match for searches.
  113.   -G  ........  --HILITE-SEARCH
  114.                   Don't highlight any matches for searches.
  115.   -h [N]  ....  --max-back-scroll=[N]
  116.                   Backward scroll limit.
  117.   -i  ........  --ignore-case
  118.                   Ignore case in searches that do not contain uppercase.
  119.   -I  ........  --IGNORE-CASE
  120.                   Ignore case in all searches.
  121.   -j [N]  ....  --jump-target=[N]
  122.                   Screen position of target lines.
  123.   -J  ........  --status-column
  124.                   Display a status column at left edge of screen.
  125.   -k [file]  .  --lesskey-file=[file]
  126.                   Use a lesskey file.
  127.   -L  ........  --no-lessopen
  128.                   Ignore the LESSOPEN environment variable.
  129.   -m  -M  ....  --long-prompt  --LONG-PROMPT
  130.                   Set prompt style.
  131.   -n  -N  ....  --line-numbers  --LINE-NUMBERS
  132.                   Use line numbers.
  133.   -o [file]  .  --log-file=[file]
  134.                   Copy to log file (standard input only).
  135.   -O [file]  .  --LOG-FILE=[file]
  136.                   Copy to log file (unconditionally overwrite).
  137.   -p [pattern]  --pattern=[pattern]
  138.                   Start at pattern (from command line).
  139.   -P [prompt]   --prompt=[prompt]
  140.                   Define new prompt.
  141.   -q  -Q  ....  --quiet  --QUIET  --silent --SILENT
  142.                   Quiet the terminal bell.
  143.   -r  -R  ....  --raw-control-chars  --RAW-CONTROL-CHARS
  144.                   Output "raw" control characters.
  145.   -s  ........  --squeeze-blank-lines
  146.                   Squeeze multiple blank lines.
  147.   -S  ........  --chop-long-lines
  148.                   Chop long lines.
  149.   -t [tag]  ..  --tag=[tag]
  150.                   Find a tag.
  151.   -T [tagsfile] --tag-file=[tagsfile]
  152.                   Use an alternate tags file.
  153.   -u  -U  ....  --underline-special  --UNDERLINE-SPECIAL
  154.                   Change handling of backspaces.
  155.   -V  ........  --version
  156.                   Display the version number of "less".
  157.   -w  ........  --hilite-unread
  158.                   Highlight first new line after forward-screen.
  159.   -W  ........  --HILITE-UNREAD
  160.                   Highlight first new line after any forward movement.
  161.   -x [N[,...]]  --tabs=[N[,...]]
  162.                   Set tab stops.
  163.   -X  ........  --no-init
  164.                   Don't use termcap init/deinit strings.
  165.                 --no-keypad
  166.                   Don't use termcap keypad init/deinit strings.
  167.   -y [N]  ....  --max-forw-scroll=[N]
  168.                   Forward scroll limit.
  169.   -z [N]  ....  --window=[N]
  170.                   Set size of window.
  171.   -" [c[c]]  .  --quotes=[c[c]]
  172.                   Set shell quote characters.
  173.   -~  ........  --tilde
  174.                   Don't display tildes after end of file.
  175.   -# [N]  ....  --shift=[N]
  176.                   Horizontal scroll amount (0 = one half screen width)
  177. ---------------------------------------------------------------------------
  178.                           LINE EDITING
  179.         These keys can be used to edit text being entered
  180.         on the "command line" at the bottom of the screen.
  181. RightArrow                       ESC-l     Move cursor right one character.
  182. LeftArrow                        ESC-h     Move cursor left one character.
  183. CNTL-RightArrow  ESC-RightArrow  ESC-w     Move cursor right one word.
  184. CNTL-LeftArrow   ESC-LeftArrow   ESC-b     Move cursor left one word.
  185. HOME                             ESC-0     Move cursor to start of line.
  186. END                              ESC-$     Move cursor to end of line.
  187. BACKSPACE                                  Delete char to left of cursor.
  188. DELETE                           ESC-x     Delete char under cursor.
  189. CNTL-BACKSPACE   ESC-BACKSPACE             Delete word to left of cursor.
  190. CNTL-DELETE      ESC-DELETE      ESC-X     Delete word under cursor.
  191. CNTL-U           ESC (MS-DOS only)         Delete entire line.
  192. UpArrow                          ESC-k     Retrieve previous command line.
  193. DownArrow                        ESC-j     Retrieve next command line.
  194. TAB                                        Complete filename & cycle.
  195. SHIFT-TAB                        ESC-TAB   Complete filename & reverse cycle.
  196. CNTL-L                                     Complete filename, list all.
  197. HELP -- END -- Press g to see it again, or q when done
复制代码


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4637/showart_328633.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP