1.使用HISTTIMEFORMAT 显示时间戳当您从命令行执行历史命令时,通常只显示执行命令的序列号和命令本身。如果你想查看命令的时间戳,可以执行:
# 导出HISTTIMEFORMAT="%F %T"
#历史|更多的
2、使用 Ctrl + R 搜索历史Ctrl+R是我们经常使用的快捷键。这个快捷键可以让你搜索命令历史记录,当你想重复执行某个命令时,这非常有用。当找到命令时,通常可以通过再次按Enter 键来执行它。如果要在执行之前调整找到的命令,可以按向左或向右箭头键。
3.快速重复执行上一条命令有4种方法可以重复执行上一条命令。
1. 使用向上键并按Enter 执行
2.按!并按Enter 执行
3、输入!-1回车执行
4.按Ctrl+P并回车执行
4.从命令历史中执行一个指定的命令如果想在后面的历史记录中重复执行命令1011,可以执行!1011
5.通过指定关键字来执行以前的命令在下面的例子中,输入!ech并回车即可执行以ech开头的命令:
6.使用HISTSIZE 控制历史命令记录的总行数将以下两行追加到.bash_profile文件中,并再次登录bash shell。命令历史记录数将变为300 条。
# vim ~/.bash_profile
历史大小=300
历史文件大小=300
7.使用HISTCONTROL 从命令历史中删除连续重复的命令# 导出HISTCONTROL=ignoredups
8.使用HISTCONTROL 清楚整个命令历史中重复的条目# 导出HISTCONTROL=erasedups
9使用HISTCONTROL 强制 history 不记录特定的命令将HISTCONTROL 设置为ignorespase,并在您不想记住的命令前输入一个空格。
# 导出HISTCONTROL=erasedups
10.使用-c选项清楚所有的命令历史#历史记录-c
11.命令替换!$ 将为当前命令获取上一条命令的参数(!$ 也可以达到同样的效果)
!^获取上一条命令的第一个参数
12.为特定的命令指定特定的参数下面的例子中,cp:2从历史命令中查找以cp开头的命令,并获取其第二个参数
13. **使用HISTSIZE 禁用历史记录**
如果要禁用历史记录,可以将HISTSIZE 设置为0
# 导出HISTSIZE=0
14.使用 HISTIGNORE 忽略历史中的特定命令以下示例中将忽略pwd、ls、ls -ltr 命令:
【世纪变迁:探索历史的长河】相关文章:
用户评论
历史 really fascinating, it helps us understand where we are today.
有6位网友表示赞同!
Learning about the past is so important! It shapes our future.
有13位网友表示赞同!
I love reading about ancient civilizations and their stories.
有15位网友表示赞同!
History is full of surprises - you never know what you're going to learn.
有7位网友表示赞同!
Sometimes I just think about how much has changed over time. Amazing!
有6位网友表示赞同!
My favorite history class was about the Renaissance - so much art and innovation!
有6位网友表示赞同!
I find it interesting to see how people lived in different eras.
有18位网友表示赞同!
History gives us perspective on current events.
有17位网友表示赞同!
It's important to remember the lessons of the past.
有14位网友表示赞同!
Historical documentaries are always so captivating.
有18位网友表示赞同!
Learning about different cultures through history is really cool.
有7位网友表示赞同!
I wish I had more time to explore history books and museums.
有17位网友表示赞同!
It's amazing how much technology has advanced over the centuries.
有14位网友表示赞同!
History is full of heroes and villains - it makes for great storytelling!
有6位网友表示赞同!
I think everyone should study some history - it's truly enriching.
有5位网友表示赞同!
Sometimes I wonder what historical figures would think about today's world.
有11位网友表示赞同!
Learning about war through history can be both tragic and thought-provoking.
有15位网友表示赞同!
History helps us appreciate the present moment.
有15位网友表示赞同!
I love visiting historical sites and seeing things for myself.
有15位网友表示赞同!