質問編集履歴

3

Add Solution

2021/06/12 09:04

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -83,3 +83,41 @@
83
83
  E-mail bug reports to: <bug-sed@gnu.org>.
84
84
 
85
85
  ```
86
+
87
+
88
+
89
+ # @otn 様の解決方法を試したところ、無事解決しました!
90
+
91
+
92
+
93
+ > LANG=C(マルチバイト文字無し)として処理すれば良いかと思います。
94
+
95
+
96
+
97
+ @otn 様、ありがとうございました!!!
98
+
99
+
100
+
101
+ ``` bash
102
+
103
+ test % cat sjis_convert.sh
104
+
105
+ #!/bin/bash
106
+
107
+ LANG=C
108
+
109
+
110
+
111
+ cat sjis_sample.csv |\
112
+
113
+ gsed -r 's/"(.*)","(.*)"/\1 \2/' |\
114
+
115
+ iconv -f shift_jis -t utf-8
116
+
117
+
118
+
119
+ test % ./sjis_convert.sh
120
+
121
+ こんにちは hello%
122
+
123
+ ```

2

Added code snipet

2021/06/12 09:04

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,21 @@
6
6
 
7
7
 
8
8
 
9
+ ``` bash
10
+
9
- ![イメージ説明](d7d10e718eb9ec1ad2e4eb58585c1631.png)
11
+ test % cat sjis_sample.csv | iconv -f shift_jis -t utf-8
12
+
13
+ "こんにちは","hello"%
14
+
15
+ test % cat sjis_sample.csv | iconv -f shift_jis -t utf-8 | gsed -r 's/"(.*)","(.*)"/\1 \2/'
16
+
17
+ こんにちは hello%
18
+
19
+ test % cat sjis_sample.csv | gsed -r 's/"(.*)","(.*)"/\1 \2/' | iconv -f shift_jis -t utf-8
20
+
21
+ "こんにちは","hello"%
22
+
23
+ ```
10
24
 
11
25
 
12
26
 

1

Added gsed version

2021/06/12 08:57

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -28,4 +28,44 @@
28
28
 
29
29
 
30
30
 
31
+ もしくはファイルからマルチバイト文字列のみ抜き出す他の方法をご存知の方いらっしゃいましたら教えてください。
32
+
33
+
34
+
31
35
  よろしくお願いします。
36
+
37
+
38
+
39
+ ``` plain
40
+
41
+ % gsed --version
42
+
43
+ gsed (GNU sed) 4.8
44
+
45
+ Copyright (C) 2020 Free Software Foundation, Inc.
46
+
47
+ License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
48
+
49
+ This is free software: you are free to change and redistribute it.
50
+
51
+ There is NO WARRANTY, to the extent permitted by law.
52
+
53
+
54
+
55
+ Written by Jay Fenlason, Tom Lord, Ken Pizzini,
56
+
57
+ Paolo Bonzini, Jim Meyering, and Assaf Gordon.
58
+
59
+
60
+
61
+ This sed program was built without SELinux support.
62
+
63
+
64
+
65
+ GNU sed home page: <https://www.gnu.org/software/sed/>.
66
+
67
+ General help using GNU software: <https://www.gnu.org/gethelp/>.
68
+
69
+ E-mail bug reports to: <bug-sed@gnu.org>.
70
+
71
+ ```