Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1790068
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: LINUX

2016-11-22 17:54:49

1.  history 这个命令
一开始我以为是history 是个binary ,单后来搞清楚它是bash的builtin . 
which history 没有输出,help history 可以查看history 帮助

点击(此处)折叠或打开

  1. root@kali:/usr/local/src/py/network# man -k history
  2. byobu-ugraph (1) - helper script for notification history graphs
  3. Date::Manip::History (3pm) - Twenty years and still going strong
  4. history (3readline) - GNU History Library
  5. latex-git-log (1) - Generates the version history of a git project as LaTeX source code.
  6. pam_pwhistory (8) - PAM module to remember last passwords
  7. Term::ReadLine::Gnu (3pm) - Perl extension for the GNU Readline/History Library
  8. XDisplayMotionBufferSize (3) - send events and pointer motion history structure
  9. XGetMotionEvents (3) - send events and pointer motion history structure
  10. XSendEvent (3) - send events and pointer motion history structure
  11. XTimeCoord (3) - send events and pointer motion history structure
  12. root@kali:/usr/local/src/py/network# which history
  13. root@kali:/usr/local/src/py/network# help history
  14. history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
  15. ...
修改了下~/.bashrc ,增加了命令行的输出timestamp.

点击(此处)折叠或打开

  1. # don't put duplicate lines or lines starting with space in the history.
  2. # See bash(1) for more options
  3. HISTCONTROL=ignoreboth

  4. # append to the history file, don't overwrite it
  5. shopt -s histappend

  6. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  7. #HISTSIZE=1000
  8. #HISTFILESIZE=2000
  9. HISTSIZE=10000
  10. HISTFILESIZE=20000

  11. #add time stamp
  12. HISTTIMEFORMAT='%F %T'

  13. # check the window size after each command and, if necessary,
  14. # update the values of LINES and COLUMNS.
  15. shopt -s checkwinsize
参考资料: 

2. diff 命令技巧
diff -a : 强行将两个文件看做text file 来比.
diff 的normal output 本身已经过时了,比较难读
diff 可以输出difference in context,分为context format 和unified format, 可以参看这里,生成patch 也主要使用这两种format, git diff 命令也使用unified format 的方式来打印出文件的不同。

下面是具体的例子:
生成两个diff 使用的文件

点击(此处)折叠或打开

  1. root@kali:~# cat <<EOF >lao
  2. > The Way that can be told of is not the eternal Way;
  3. > The name that can be named is not the eternal name.
  4. > The Nameless is the origin of Heaven and Earth;
  5. > The Named is the mother of all things.
  6. > Therefore let there always be non-being,
  7. > so we may see their subtlety,
  8. > And let there always be being,
  9. > so we may see their outcome.
  10. > The two are the same,
  11. > But after they are produced,
  12. > they have different names.
  13. > EOF

点击(此处)折叠或打开

  1. root@kali:~# cat <<EOF >tzu
  2. > The Nameless is the origin of Heaven and Earth;
  3. > The named is the mother of all things.
  4. >
  5. > Therefore let there always be non-being,
  6. > so we may see their subtlety,
  7. > And let there always be being,
  8. > so we may see their outcome.
  9. > The two are the same,
  10. > But after they are produced,
  11. > they have different names.
  12. > They both may be called deep and profound.
  13. > Deeper and more profound,
  14. > The door of all
  15. > EOF

点击(此处)折叠或打开

  1. root@kali:~# diff -q lao tzu
  2. Files lao and tzu differ

  3. root@kali:~# echo $?
  4. 1

  5. root@kali:~# diff lao tzu
  6. 1,2d0
  7. < The Way that can be told of is not the eternal Way;
  8. < The name that can be named is not the eternal name.
  9. 4c2,3
  10. < The Named is the mother of all things.
  11. ---
  12. > The named is the mother of all things.
  13. >
  14. 11a11,13
  15. > They both may be called deep and profound.
  16. > Deeper and more profound,
  17. > The door of all

  18. root@kali:~# diff -y lao tzu
  19. The Way that can be told of is not the eternal Way;     <
  20. The name that can be named is not the eternal name.     <
  21. The Nameless is the origin of Heaven and Earth;            The Nameless is the origin of Heaven and Earth;
  22. The Named is the mother of all things.             |    The named is the mother of all things.
  23.                              >
  24. Therefore let there always be non-being,            Therefore let there always be non-being,
  25.   so we may see their subtlety,                     so we may see their subtlety,
  26. And let there always be being,                    And let there always be being,
  27.   so we may see their outcome.                     so we may see their outcome.
  28. The two are the same,                        The two are the same,
  29. But after they are produced,                    But after they are produced,
  30.   they have different names.                     they have different names.
  31.                              >    They both may be called deep and profound.
  32.                              >    Deeper and more profound,
  33.                              >    The door of all

  34. root@kali:~# diff -y -l lao tzu


  35. 2016-11-22 17:43 diff -y -l lao tzu Page 1


  36. The Way that can be told of is not the eternal Way;     <
  37. The name that can be named is not the eternal name.     <
  38. The Nameless is the origin of Heaven and Earth;            The Nameless is the origin of Heaven and Earth;
  39. The Named is the mother of all things.             |    The named is the mother of all things.
  40.                              >
  41. Therefore let there always be non-being,            Therefore let there always be non-being,
  42.   so we may see their subtlety,                     so we may see their subtlety,
  43. And let there always be being,                    And let there always be being,
  44.   so we may see their outcome.                     so we may see their outcome.
  45. The two are the same,                        The two are the same,
  46. But after they are produced,                    But after they are produced,
  47.   they have different names.                     they have different names.
  48.                              >    They both may be called deep and profound.
  49.                              >    Deeper and more profound,
  50.                              >    The door of all

感觉也就下面这些参数比较常用了

点击(此处)折叠或打开

  1. -q, --brief: report only when files differ
  2. -c, -C NUM, --context[=NUM] : output NUM (default 3) lines of copied context
  3. -u, -U NUM, --unified[=NUM] : output NUM (default 3) lines of unified context
  4. -l, --paginate: pass output through `pr`
  5. -e, --ed : output an ed script
  6. -y, --side-by-side: output in two columns



阅读(1018) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~