覆盖现有文件时,如何使bash警告我?


34

我认为标题是不言自明的。我想要的只是bash在使用cp或时尝试覆盖现有文件时警告我mv。我真的很感谢您的帮助。:)

Answers:


43

您应该使用交互式模式,以确保获得“覆盖前提示”

cp --interactive
mv --interactive

或总之

cp -i
mv -i

键入man cpman mv在命令行上,以了解更多信息。


2
因此,我猜命令的那些也将在我的.bashrc中作为别名使用。非常感谢。感谢你的帮助。:)
sayantankhan

3
确实!您可以将类似的内容附加alias rm='rm -i'到.bashrc或更好的.bash_aliases中。在文章中阅读更多信息如何创建永久的Bash别名?
don.joey 2013年

2
但是我只是想到了什么。那我写的一些脚本呢?他们会使用别名的cp和mv还是普通的别名?
sayantankhan

@ Bolt64这取决于您将别名定义放在何处,但是通常它将使用普通的别名定义。
JanWarchoł16年

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.