1. history 这个命令
一开始我以为是history 是个binary ,单后来搞清楚它是bash的builtin .
which history 没有输出,help history 可以查看history 帮助
-
root@kali:/usr/local/src/py/network# man -k history
-
byobu-ugraph (1) - helper script for notification history graphs
-
Date::Manip::History (3pm) - Twenty years and still going strong
-
history (3readline) - GNU History Library
-
latex-git-log (1) - Generates the version history of a git project as LaTeX source code.
-
pam_pwhistory (8) - PAM module to remember last passwords
-
Term::ReadLine::Gnu (3pm) - Perl extension for the GNU Readline/History Library
-
XDisplayMotionBufferSize (3) - send events and pointer motion history structure
-
XGetMotionEvents (3) - send events and pointer motion history structure
-
XSendEvent (3) - send events and pointer motion history structure
-
XTimeCoord (3) - send events and pointer motion history structure
-
root@kali:/usr/local/src/py/network# which history
-
root@kali:/usr/local/src/py/network# help history
-
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
-
...
修改了下~/.bashrc ,增加了命令行的输出timestamp.
-
# don't put duplicate lines or lines starting with space in the history.
-
# See bash(1) for more options
-
HISTCONTROL=ignoreboth
-
-
# append to the history file, don't overwrite it
-
shopt -s histappend
-
-
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
-
#HISTSIZE=1000
-
#HISTFILESIZE=2000
-
HISTSIZE=10000
-
HISTFILESIZE=20000
-
-
#add time stamp
-
HISTTIMEFORMAT='%F %T'
-
-
# check the window size after each command and, if necessary,
-
# update the values of LINES and COLUMNS.
-
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 使用的文件
-
root@kali:~# cat <<EOF >lao
-
> The Way that can be told of is not the eternal Way;
-
> The name that can be named is not the eternal name.
-
> The Nameless is the origin of Heaven and Earth;
-
> The Named is the mother of all things.
-
> Therefore let there always be non-being,
-
> so we may see their subtlety,
-
> And let there always be being,
-
> so we may see their outcome.
-
> The two are the same,
-
> But after they are produced,
-
> they have different names.
-
> EOF
-
root@kali:~# cat <<EOF >tzu
-
> The Nameless is the origin of Heaven and Earth;
-
> The named is the mother of all things.
-
>
-
> Therefore let there always be non-being,
-
> so we may see their subtlety,
-
> And let there always be being,
-
> so we may see their outcome.
-
> The two are the same,
-
> But after they are produced,
-
> they have different names.
-
> They both may be called deep and profound.
-
> Deeper and more profound,
-
> The door of all
-
> EOF
-
root@kali:~# diff -q lao tzu
-
Files lao and tzu differ
-
-
root@kali:~# echo $?
-
1
-
-
root@kali:~# diff lao tzu
-
1,2d0
-
< The Way that can be told of is not the eternal Way;
-
< The name that can be named is not the eternal name.
-
4c2,3
-
< The Named is the mother of all things.
-
---
-
> The named is the mother of all things.
-
>
-
11a11,13
-
> They both may be called deep and profound.
-
> Deeper and more profound,
-
> The door of all
-
-
root@kali:~# diff -y lao tzu
-
The Way that can be told of is not the eternal Way; <
-
The name that can be named is not the eternal name. <
-
The Nameless is the origin of Heaven and Earth; The Nameless is the origin of Heaven and Earth;
-
The Named is the mother of all things. | The named is the mother of all things.
-
>
-
Therefore let there always be non-being, Therefore let there always be non-being,
-
so we may see their subtlety, so we may see their subtlety,
-
And let there always be being, And let there always be being,
-
so we may see their outcome. so we may see their outcome.
-
The two are the same, The two are the same,
-
But after they are produced, But after they are produced,
-
they have different names. they have different names.
-
> They both may be called deep and profound.
-
> Deeper and more profound,
-
> The door of all
-
-
root@kali:~# diff -y -l lao tzu
-
-
-
2016-11-22 17:43 diff -y -l lao tzu Page 1
-
-
-
The Way that can be told of is not the eternal Way; <
-
The name that can be named is not the eternal name. <
-
The Nameless is the origin of Heaven and Earth; The Nameless is the origin of Heaven and Earth;
-
The Named is the mother of all things. | The named is the mother of all things.
-
>
-
Therefore let there always be non-being, Therefore let there always be non-being,
-
so we may see their subtlety, so we may see their subtlety,
-
And let there always be being, And let there always be being,
-
so we may see their outcome. so we may see their outcome.
-
The two are the same, The two are the same,
-
But after they are produced, But after they are produced,
-
they have different names. they have different names.
-
> They both may be called deep and profound.
-
> Deeper and more profound,
-
> The door of all
感觉也就下面这些参数比较常用了
-
-q, --brief: report only when files differ
-
-c, -C NUM, --context[=NUM] : output NUM (default 3) lines of copied context
-
-u, -U NUM, --unified[=NUM] : output NUM (default 3) lines of unified context
-
-l, --paginate: pass output through `pr`
-
-e, --ed : output an ed script
-
-y, --side-by-side: output in two columns
阅读(1018) | 评论(0) | 转发(0) |