1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windowsでファイル内テキスト検索

Posted at

概要

「〇〇って書いてあるファイルがどこに行ったか分からない」「個人情報が入っているファイルを探したい」といった場合にPowerShellを使用して検索する方法

参考:Select-String (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs

※検索に使用しているファイルに記載されている個人名は[疑似個人情報データ生成サービス]を使用して生成しており、実際に存在するものではありません。

コマンド

Select-String 検索するフォルダ -pattern 検索文字列
使用例
(ファイルを検索するフォルダでShift+右クリック [PowerShellウィンドウをここで開く]Powershellを実行)

PS C:\>Select-String *.* -pattern 田中

personal_infomation1.csv:15:14,田中修子,タナカシュウコ,,0798418030,1969/01/07

PS C:\> Select-String *.* -pattern 

personal_infomation2.csv:2:1,岩谷盛夫,イワタニモリオ,,0125635115,1969/01/10
personal_infomation2.csv:35:34,浜野定夫,ハマノサダオ,,0326502254,1971/09/11
personal_infomation2.csv:72:71,白川明夫,シラカワアキオ,,0893529050,1982/10/09
personal_infomation2.csv:86:85,米沢政夫,ヨネザワマサオ,,0271615143,1984/08/24
personal_infomation3.csv:30:29,大谷光夫,オオヤミツオ,,0944136870,1987/10/19
personal_infomation3.csv:69:68,大場照夫,オオバテルオ,,0769047463,1985/11/06
personal_infomation4.csv:5:4,白木哲夫,シラキテツオ,,0338896081,1970/01/10
personal_infomation4.csv:6:5,香川悦夫,カガワエツオ,,0424848009,1989/06/29
personal_infomation4.csv:48:47,坂田郁夫,サカタイクオ,,0186750955,1984/08/11
personal_infomation4.csv:85:84,山上忠夫,ヤマガミタダオ,,0879011016,1988/09/02

Appendix

コマンドプロンプトの場合

find "検索文字" *

Linuxの場合

grep -ir "検索文字" .
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?