Insert data into the file as an array in bash

Viewed 175

With the below command, i'm writing data into file.txt.

node scripts/js/script.js /home/desktop/my-file.mp3 > file.txt

The content of file.txt:

0
0
0
0
0
0.00003051850947599719
0
-0.00003051850947599719
0
0.00006103701895199438
0

What should be way such that it writes the data in the form of an array? Like this:

[0, 0, 0, 0, 0.00003051850947599719, 0, -0.00003051850947599719, 0, 0.00006103701895199438, 0]

Thanks in advance.

3 Answers
Related