2016-11-16 73 views
-2

我有大量的Web应用程序视图以火焰编写。在举行这些文件我的终端 我的文件夹看起来像这样删除文件内容并写入空文件

~/track/app/client/templates$ ls 
reports shared  users 

所有这些都是文件夹。在每个文件夹中,我有文件app.html(例如每个文件夹都有一个唯一的html名称)。

我希望能够删除模板内的任何文件夹的文件内容。我能够使用truncate -s 0 app.html删除内容,但是当我在一个文件夹内,如users时,它可以工作。

如何删除users文件夹中的内容,而不需要从根目录开始,而不需要从~/track/app/client/templates/users开始。

回答

1

使用相对路径?

truncate -s 0 users/app.html 
0

要清除文件: 尝试输入

cat> filename 

然后按Ctrl + C,其清除文件

要写入文件:

cat> filename 
Then you can write whatever you want to be in the file here. 
This will be written in the file. 

然后按ENTER键 按CTRL + C再

来源:https://askubuntu.com/questions/390167/how-to-clear-text-in-a-file

+0

你不需要CTRLC。你可以写cat> filename << EOF。当你完成你输入EOF和猫退出。 –