动态地将数据附加到文件

时间:2021-01-07 21:16:12

I have a file with a javascript code and an array below it containing lots of data. I have to add data to the array from a log file. The log file gets data continuously added to it and the new data has to be appended to the array without affecting the data previously held in the first file. Is there a way to do this using shell scripting?

我有一个带有javascript代码的文件,下面有一个包含大量数据的数组。我必须从日志文件中向数组添加数据。日志文件将数据连续添加到其中,并且新数据必须附加到数组,而不会影响先前保存在第一个文件中的数据。有没有办法使用shell脚本执行此操作?

1 个解决方案

#1


0  

You can append to files using this:

您可以使用以下方法附加到文件:

echo "Hello world" >> file.txt

And i think you need this:

而且我认为你需要这个:

cat your_file1 >> your_file2

This will append your_file1 to your_file2.

这会将your_file1附加到your_file2。

#1


0  

You can append to files using this:

您可以使用以下方法附加到文件:

echo "Hello world" >> file.txt

And i think you need this:

而且我认为你需要这个:

cat your_file1 >> your_file2

This will append your_file1 to your_file2.

这会将your_file1附加到your_file2。