2016-11-16 74 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和貓退出。 –