龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 操作系统 > LINUX系统 >

History(历史)命令用法 15 例(2)

时间:2014-05-29 15:02来源:网络整理 作者:网络 点击:
分享到:
在下面的例子,!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]

精彩图集

赞助商链接