回答編集履歴
1
補足を追加
test
CHANGED
@@ -5,6 +5,32 @@
|
|
5
5
|
```sh
|
6
6
|
|
7
7
|
$ cat sample.dat | awk 'BEGIN { print "{\"items\": ["; eol="" } { printf "%s { \"title\": \"%s\" }", eol, $0; eol=",\n" } END { print "\n]}" }'
|
8
|
+
|
9
|
+
```
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```AWK
|
14
|
+
|
15
|
+
BEGIN {
|
16
|
+
|
17
|
+
print "{\"items\": ["; eol=""
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
{
|
22
|
+
|
23
|
+
printf "%s { \"title\": \"%s\" }", eol, $0;
|
24
|
+
|
25
|
+
eol=",\n"
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
END {
|
30
|
+
|
31
|
+
print "\n]}"
|
32
|
+
|
33
|
+
}
|
8
34
|
|
9
35
|
```
|
10
36
|
|