假设您刚刚运行了十几个命令。说... $ cd foo/ # history cmd #10000 (my history is very long) $ ... more commands ... $ cd ../ # history cmd #10012 我知道,!-12 && !-11 && !-10 && (and so on) && !!如果碰巧刚运行过它们(不太可能)或!10000 && !10001 && !10002 && (and so on),我可以重新运行它们,但是有没有比在每个历史记录号上加上一个“砰”号和“&”号简单的方法呢? 在bash中也许我没有意识到某种范围的东西? 例如!{10000-10012}#这样的东西,只能工作。
我创建了以下脚本,将定义的旧文件从源目录移动到目标目录。运行良好。 #!/bin/bash echo "Enter Your Source Directory" read soure echo "Enter Your Destination Directory" read destination echo "Enter Days" read days find "$soure" -type f -mtime "-$days" -exec mv {} "$destination" \; echo "Files which were $days Days old moved from $soure to $destination" 该脚本可以很好地移动文件,它也可以移动源子目录的文件,但不会在目标目录中创建子目录。我要在其中实现此附加功能。 举个例子 /home/ketan : source directory …
我希望能够通过ssh发送信号(SIGINT最重要)。 该命令: ssh server "sleep 1000;echo f" > foo 将开始在服务器上进入睡眠状态,并在1000秒后将“ f \ n”放入本地计算机上的foo文件中。如果按CTRL-C(即,将SIGINT发送到ssh),它将杀死ssh,但不会杀死远程服务器上的睡眠。我希望它杀死远程服务器上的睡眠。 所以我尝试了: ssh server -t "sleep 1000;echo f" > foo 但是,如果stdin不是终端,则会出现此错误: Pseudo-terminal will not be allocated because stdin is not a terminal. 然后SIGINT仍然不转发。 所以我尝试了: ssh server -t -t "sleep 1000;echo f" > output 但是然后foo中的输出不是'f \ n'而是'f \ r …