回答編集履歴

3

Powershell版コードのシングルクォートの抜けを補填

2018/11/19 07:45

投稿

Turkis_Mond
Turkis_Mond

スコア94

test CHANGED
@@ -24,6 +24,6 @@
24
24
 
25
25
  ```powershell
26
26
 
27
- gci 'C:\hoge\text*wiki.*' -recurse |%{gc $_ -en oem|out-file 'C:\hoge\wiki.txt -en oem -append}
27
+ gci 'C:\hoge\text*wiki.*' -recurse |%{gc $_ -en oem|out-file 'C:\hoge\wiki.txt' -en oem -append}
28
28
 
29
29
  ```

2

コマンドプロンプトコマンドであることを明記、Powershell版のコマンドも追記

2018/11/19 07:45

投稿

Turkis_Mond
Turkis_Mond

スコア94

test CHANGED
@@ -8,10 +8,22 @@
8
8
 
9
9
  そのサイトでのgrepの使い方は単にファイル名をフィルタしてるだけなのでfindstrも不適です。
10
10
 
11
+
12
+
13
+ コマンド プロンプトではこうなります。(Powershellではありません。)
14
+
11
- バッチコマンドでの置き換えこうなります
15
+ なおバッチファイルにする場合%をに%%に変更ください
12
16
 
13
17
  ```batch
14
18
 
15
19
  for /r text\ %a in (*wiki.*) do type "%a" >>wiki.txt
16
20
 
17
21
  ```
22
+
23
+ Powershellで書くとこんな感じです。
24
+
25
+ ```powershell
26
+
27
+ gci 'C:\hoge\text*wiki.*' -recurse |%{gc $_ -en oem|out-file 'C:\hoge\wiki.txt -en oem -append}
28
+
29
+ ```

1

解説とコマンドプロンプト用のコマンドを追記

2018/11/19 07:44

投稿

Turkis_Mond
Turkis_Mond

スコア94

test CHANGED
@@ -1,5 +1,17 @@
1
- エラーが出てるのはfindstrではなくfindコマンドですね、LinuxのfindとWindowsのfindは機能が全く違いますので。
1
+ エラーが出てるのはfindstrではなくfindコマンドですね、LinuxのfindとWindowsのfindは機能が全く違いますので。Linuxのfindに近いWinのコマンドはdirになります。
2
-
3
- Linuxのfindに近いWinのコマンドはdirになります。
4
2
 
5
3
  コマンドプロンプトではなく上位版のPowershellを使った方がいいでしょう。後でコードも書き足します。
4
+
5
+
6
+
7
+ どこかで見たコマンド列だなと思ったら、先月別のQAサイトで [まったく同じ質問](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12197620887) が出て回答しました。
8
+
9
+ そのサイトでのgrepの使い方は単にファイル名をフィルタしてるだけなのでfindstrも不適です。
10
+
11
+ バッチコマンドでの置き換えはこうなります
12
+
13
+ ```batch
14
+
15
+ for /r text\ %a in (*wiki.*) do type "%a" >>wiki.txt
16
+
17
+ ```