通过ssh命令将内容添加到.js文件的末尾

时间:2013-05-30 14:46:34

标签: linux shell ssh

我正在尝试弄清楚如何使用ssh命令将内容/代码添加到已经包含代码的.js文件的末尾。

...即

touch ./ap/includes/ckeditor/ckeditor.js
Maintain current code
echo "add custom end code only"> ./ap/includes/ckeditor/ckeditor.js

1 个答案:

答案 0 :(得分:2)

ssh命令用于连接另一台服务器。

您可以将文字附加到文件末尾的是echo "something" >> /your/file

所以基于你的代码:

touch ./ap/includes/ckeditor/ckeditor.js
Maintain current code
echo "add custom end code only" >> ./ap/includes/ckeditor/ckeditor.js
                                ^
                                |_ changed this

顺便说一下,touch部分是不必要的。在文件内部回显时,将更新文件的日期。如果文件不存在,将使用echo自动创建。