回答編集履歴
4
fix
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
```
|
8
8
|
|
9
|
-
$ cat test.xml | grep -m 1 -oP "(?<=
|
9
|
+
$ cat test.xml | grep -m 1 -oP "(?<=<title>).+(?=</title>)"
|
10
10
|
|
11
11
|
```
|
12
12
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
```
|
16
16
|
|
17
|
-
$ cat test.xml | grep -oP "(?<=
|
17
|
+
$ cat test.xml | grep -oP "(?<=<title>).+(?=</title>)"
|
18
18
|
|
19
19
|
```
|
20
20
|
|
3
fix
test
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
もうベストアンサー出てしまいましたが、実は grep だけで行けます。
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
最初の1件
|
4
6
|
|
5
7
|
```
|
6
8
|
|
7
9
|
$ cat test.xml | grep -m 1 -oP "(?<=\<title\>).+(?=<\/title>)"
|
8
10
|
|
9
11
|
```
|
12
|
+
|
13
|
+
全部欲しい場合は
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
$ cat test.xml | grep -oP "(?<=\<title\>).+(?=<\/title>)"
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
|
2
fix
test
CHANGED
@@ -4,6 +4,6 @@
|
|
4
4
|
|
5
5
|
```
|
6
6
|
|
7
|
-
$ cat test.xml | grep -oP "(?<=\<title\>).+(?=<\/title>)"
|
7
|
+
$ cat test.xml | grep -m 1 -oP "(?<=\<title\>).+(?=<\/title>)"
|
8
8
|
|
9
9
|
```
|
1
fix
test
CHANGED
@@ -4,6 +4,6 @@
|
|
4
4
|
|
5
5
|
```
|
6
6
|
|
7
|
-
$ cat test.xml | grep -oP "(?<=\<title\>).+(?=<\/title>)"
|
7
|
+
$ cat test.xml | grep -oP "(?<=\<title\>).+(?=<\/title>)" | head -n 1
|
8
8
|
|
9
9
|
```
|