【发布时间】:2020-07-25 17:52:24
【问题描述】:
我想要做什么
在 Mac OS 10.15.4 上的 Bash 终端中,我正在尝试将我之前执行的命令插入到脚本文件中。
我是如何做到的
我使用下面的命令打印我之前输入的命令。
!700:p
然后我尝试使用以下命令将其插入到我的脚本文件中。
输入
!700:p >> script_file
输出
'command I'm trying to insert' >> script_file
唉,它没有插入到 script_file。
任何帮助将不胜感激!谢谢。
【问题讨论】:
-
我没有mac OS,所以无法测试,如果你有
history命令,你能不能尝试一下history | tail -n 2 |head -n 1。 -
嗨@RavinderSingh13,它返回726'我输入的命令'
-
这样好吗?您只需要正确的最后一个命令吗?
-
如果你使用
tee,!700:p | tee -a script_file会怎样 我很久以前就禁用了历史扩展,所以我真的不能说它会起作用^^。 -
嗨@Jetchisel,遗憾的是它仍然没有插入。
标签: bash shell command-line insert command