我有一个包含内容的文本文件:
//input.txt
1) What is the first month of the year?
a) March
b) February
c) January
d) December
Answer: c) January
2) What is the last month of the year?
a) July
b) December
c) August
d) May
Answer: b) December
Run Code Online (Sandbox Code Playgroud)
我想编写一个 shell 脚本,循环遍历此文件 input.txt (其中包含更多具有相同格式的内容)并生成类似于以下 JSON 的输出
[
{
"question": "What is the first month of the year?",
"a": "March",
"b": "February",
"c": "January",
"d": "December",
"answer": "January",
},
{
"question": "What is the last month of the …Run Code Online (Sandbox Code Playgroud)