History(历史)命令用法 15 例(2)
在下面的例子,!cp:2 从命令历史中搜索以 cp 开头的命令,并获取它的第二项参数: # cp ~/longname.txt /really/a/very/long/path/long-filename.txt# ls -l !cp:2ls -l /really/a
在下面的例子,!cp:2 从命令历史中搜索以 cp 开头的命令,并获取它的第二项参数:
# cp ~/longname.txt /really/a/very/long/path/long-filename.txt
# ls -l !cp:2
ls -l /really/a/very/long/path/long-filename.txt
下例里,!cp:$ 获取 cp 命令的最后一项参数:
# ls -l !cp:$
ls -l /really/a/very/long/path/long-filename.txt
使用 HISTSIZE 禁用 history
如果你想禁用 history,可以将 HISTSIZE 设置为 0:
# export HISTSIZE=0
# history
# [Note that history did not display anything]
使用 HISTIGNORE 忽略历史中的特定命令
下面的例子,将忽略 pwd、ls、ls -ltr 等命令:
# export HISTIGNORE=”pwd:ls:ls -ltr:”
# pwd
# ls
# ls -ltr
# service httpd stop
# history | tail -3
79 export HISTIGNORE=”pwd:ls:ls -ltr:”
80 service httpd stop
81 history
[Note that history did not record pwd, ls and ls -ltr]
[via The Geek Stuff]
- 上一篇:Linux 国际化本地化和中文化
- 下一篇:配置 yum 源的两种方法
收藏文章
精彩图集
精彩文章