我只是想复习一下基本的终端命令。说到这里,我如何只用终端来创建一个文本文件?
touch ~/Desktop/something.txt
这将创建一个空的`txt'文件。
或者
echo "Hello" > ~/Desktop/somethingelse.txt
这将创建一个`txt'文件,内容是"Hello"。
nano ~/Desktop/anotherfile.txt
这将在nano
中打开~/Desktop/anotherfile.txt
,如果它不存在,它将创建它并在nano
中打开它。
同样可以通过简单地将nano
替换为emacs
或vim
来实现,它将使用emacs
或vim
而不是nano
。
你可以使用nano、vi或emacs编辑程序,在终端层面上创建文件。如果你使用x windows系统,你需要告诉你的系统不要在GUI中使用该程序;但无论如何,我将使用emacs作为一个例子。
从bash中;输入
emacs filename.txt (press enter) - it will create an empty file with the filename specified "filename.txt". It will save "filename.txt" from which ever
directory type in "emacs filename.txt" command.
请记住,在所有的UNIX系统中,VI是自带的;而emacs不是,你需要安装emacs。另一方面,Nano更受欢迎;以防万一,如果它没有反应,这意味着当你"nano filename.ext"时,没有任何反应,你就需要安装它。
一旦你发出vi filename.txt,很可能你就会创建一个新的文件。在你开始之前,你应该在google上查找vi、emacs或nano的使用方法。在这些编辑程序中,如何编写文件、编辑文件、使用其工具来搜索和替换文本是不同的。在所有的选择中,我喜欢emacs,但你会发现有的开发者对vi和nano情有独钟或青睐有加。