相关疑难解决方法(0)

有没有办法从历史中执行命令?

例如:

[root@ip-10-0-7-125 ~]# history | grep free
  594  free -m
  634  free -m | xargs | awk '{print "free/total memory" $17 " / " $ 8}'
  635  free -m
  636  free -m | xargs | awk '{print "free/total memory" $9 " / " $ 10}'
  736  df -h | xargs |  awk '{print "free/total disk: " $11 " / " $9}'
  740  df -h | xargs |  awk '{print "free/total disk: " $11 " / " $8}'
  741  free -m …
Run Code Online (Sandbox Code Playgroud)

bash command-history

153
推荐指数
5
解决办法
10万
查看次数

不能在 bash 中使用感叹号 (!)?

我正在尝试使用 curl 命令访问!路径中带有感叹号 ( )的 http url 。例如:

curl -v "http://example.org/!287s87asdjh2/somepath/someresource"
Run Code Online (Sandbox Code Playgroud)

控制台回复bash: ... event not found.

这里发生了什么?逃避感叹号的正确语法是什么?

bash special-characters quoting

148
推荐指数
6
解决办法
13万
查看次数

为什么 bash 仍然保留带有擦除的重复行?

我的 ~/.bashrc 中有以下行

export HISTCONTROL=ignoreboth:erasedups
Run Code Online (Sandbox Code Playgroud)

但是,每当我运行somecommand它时,它都会.bash_history像这样添加重复的命令

grep -w somecommand ~/.bash_history
somecommand
somecommand abc xyz
somecommand 123
somecommand
...
Run Code Online (Sandbox Code Playgroud)

为什么会这样以及如何预防?

bash command-history

6
推荐指数
2
解决办法
1742
查看次数