如何从终端窗口在Linux中创建文件? [英] How to create a file in Linux from terminal window?
本文介绍了如何从终端窗口在Linux中创建文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Linux终端中创建文件的最简单方法是什么?
What's the easiest way to create a file in Linux terminal?
推荐答案
取决于您希望文件包含的内容:
Depending on what you want the file to contain:
-
touch /path/to/file
表示一个空文件 -
somecommand > /path/to/file
表示包含某些命令输出的文件.
touch /path/to/file
for an empty filesomecommand > /path/to/file
for a file containing the output of some command.
eg: grep --help > randomtext.txt
echo "This is some text" > randomtext.txt
nano /path/to/file
或vi /path/to/file
(或any other editor emacs,gedit etc
)
它要么打开现有的文件进行编辑,要么创建&打开空文件以输入(如果不存在)
nano /path/to/file
or vi /path/to/file
(or any other editor emacs,gedit etc
)
It either opens the existing one for editing or creates & opens the empty file to enter, if it doesn't exist
这篇关于如何从终端窗口在Linux中创建文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文