3

在 bash 中输入了一个长命令后,出于某种原因,我决定不执行它。但我只是想在没有清除命令的情况下开始一个新行。那个命令还在屏幕上?来人帮帮我?

#I typed as below:
$>find -name "filepattern" -exec grep "hello" {} \;

#I wanted as below without executing the 'find' command.
$>find -name "filepattern" -exec grep "hello" {} \;
$>
4

4 回答 4

6

一个有用的 bash 快捷方式是Alt#注释掉当前命令。

例如:

$ find -name "filepattern" -exec grep "hello" {} \; <Alt+#>
$ #find -name "filepattern" -exec grep "hello" {} \; 
$

我喜欢这个,因为它将命令存储在您的历史记录中。然后您可以返回到它,删除#并运行它。随着Ctrl+C你失去你写的命令。

于 2012-12-11T13:21:55.357 回答
3

您可以使用ctrlc“取消”您键入的命令。

我在 OS X 上的测试:

bash-3.2$ find -name "filepattern" -exec grep "hello" {} \; <ctrl+c>
bash-3.2$ 

bash-3.2$ /bin/bash -version
/bin/bash -version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
bash-3.2$ 
于 2012-12-11T12:36:52.940 回答
2

一种临时解决方案是在当前行的开头添加一个“#”以将其转换为注释。

于 2012-12-11T12:40:53.290 回答
2

ctrlu给你一个新的开始。您可以继续使用之前键入的旧命令ctrly

于 2013-03-25T05:18:53.707 回答