linux – Up Arrow的替代方案输入以运行上一个命令?
发布时间:2020-05-27 17:07:11 所属栏目:Linux 来源:互联网
导读:有时我必须连续多次运行命令,例如查看服务是否已启动,将手移离正常输入位置以反复按向上箭头和输入键变得乏味.有没有办法在没有Up Arrow和Enter键的情况下运行上一个命令,可能还有一个精心设计的shell脚本?我已经尝试了以下内容,但它不能令人满意,因为它无法
|
有时我必须连续多次运行命令,例如查看服务是否已启动,将手移离正常输入位置以反复按向上箭头和输入键变得乏味.有没有办法在没有Up Arrow和Enter键的情况下运行上一个命令,可能还有一个精心设计的shell脚本? 我已经尝试了以下内容,但它不能令人满意,因为它无法执行别名,而且速度有点慢.
理想情况下,我有一个这个脚本的别名,所以我可以在命令行中键入类似“prev”的内容,然后按Enter键再次运行上一个命令. 最佳答案 在bash中:
$help fc
fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]
Display or execute commands from the history list.
fc is used to list or edit and re-execute commands from the history list.
FIRST and LAST can be numbers specifying the range,or FIRST can be a
string,which means the most recent command beginning with that
string.
Options:
-e ENAME select which editor to use. Default is FCEDIT,then EDITOR,then vi
-l list lines instead of editing
-n omit line numbers when listing
-r reverse the order of the lines (newest listed first)
With the `fc -s [pat=rep ...] [command]' format,COMMAND is
re-executed after the substitution OLD=NEW is performed.
A useful alias to use with this is r='fc -s',so that typing `r cc'
runs the last command beginning with `cc' and typing `r' re-executes
the last command.
Exit Status:
Returns success or status of executed command; non-zero if an error occurs.
注意别名r的建议;我经常使用它. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – / var / opt / vs / var / lib
- linux只按照每一行的第一个字母进行排序
- linux – SSH访问问题:debug1:期待SSH2_MSG_KEX_DH_GEX_R
- linux – pthreads线程在堆栈中预先故障的最佳方法是什么?
- Linux – Shell脚本并行运行curl命令
- linux – 在debian中创建虚拟包的最简单方法是什么?
- linux – 如何在不重启的情况下免费交换(以避免每小时警报电
- linux – DDOS攻击下的服务器 – 如何查找IP?
- linux – 如何允许多人通过sftp更改文件的mtime -timestamp
- grep或sed找到一个超过给定数量的整数值?
