LQ Newbie
Registered: Mar 2008
Location: Seguin, Texas
Distribution: Red Hat 9
Posts: 10
Original Poster
Rep:
|
Parsing text string into array in bash scripot
Sorry for the lack of information all. I'm running on CentOS 6.4 64-bit. The source text string looks like
[{"date":1399507200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399510800000,"abcdefg" :0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399514400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwx yz":0},{"date":1399518000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399521600000,"a bcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399525200000,"abcdefg":0,"hijklmn":0,"opqrstu" :0,"vwxyz":0},{"date":1399528800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":139953240 0000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399536000000,"abcdefg":0,"hijklmn":0,"o pqrstu":0,"vwxyz":0},{"date":1399539600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":13 99543200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399546800000,"abcdefg":0,"hijklm n":0,"opqrstu":0,"vwxyz":0},{"date":1399550400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"d ate":1399554000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399557600000,"abcdefg":0, "hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399561200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz" :0},{"date":1399564800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399568400000,"abcd efg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399572000000,"abcdefg":0,"hijklmn":0,"opqrstu":0, "vwxyz":0},{"date":1399575600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":139957920000 0,"abcdefg":1220,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":1399582800000,"abcdefg":0,"hijklmn":0,"o pqrstu":0,"vwxyz":0},{"date":1399586400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},{"date":13 99590000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0}]
but it's all one continuous string containing no newline characters. I need to put it into an array with each of the array elements looking like:
[{"date":1399507200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399510800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399514400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399518000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399521600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399525200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399528800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399532400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399536000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399539600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399543200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399546800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399550400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399554000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399557600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399561200000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399564800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399568400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399572000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399575600000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399579200000,"abcdefg":1220,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399582800000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399586400000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0},
{"date":1399590000000,"abcdefg":0,"hijklmn":0,"opqrstu":0,"vwxyz":0}]
The leading and trailing braces ([]) can be removed.
The reason I wanted to place it into an array is because I have to perform some post-processing on various fields of each entry. Let me know if additional information is necessary.
Thank you
|