Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 从Unix中的另一个目录在某个目录中创建文本文件_Bash_Unix - Fatal编程技术网

Bash 从Unix中的另一个目录在某个目录中创建文本文件

Bash 从Unix中的另一个目录在某个目录中创建文本文件,bash,unix,Bash,Unix,我想知道如果您想从unix中的另一个目录在某个目录中创建文件,代码会是什么样子 例如: File to be created: pop.txt Directory to create that in: /home/p1 Directory you are currently in and are to make it from: /home/pokemon/master/ 谢谢 就这么简单你可以用这种方法。 因为触摸只能创建一个空文件。但这也可以添加内容 cat>/home/p1/pop.tx

我想知道如果您想从unix中的另一个目录在某个目录中创建文件,代码会是什么样子

例如:

File to be created: pop.txt
Directory to create that in: /home/p1
Directory you are currently in and are to make it from: /home/pokemon/master/
谢谢

就这么简单

你可以用这种方法。 因为触摸只能创建一个空文件。但这也可以添加内容

cat>/home/p1/pop.txt

vim>/home/p1/pop.txt

在终端中使用cat。维姆是一名编辑

还有其他方法可以用吗

cat>./../p1/pop.txt

vim.././p1/pop.txt


。。表示返回参考或上一个目录。

如果答案正确,请将其标记为正确。否则堆栈溢出将不知道问题是否已解决。
touch /home/p1/pop.txt