0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsバッチ(.bat)学習メモ FINDコマンド

Posted at

FINDコマンドは、ファイル内に記載されている内容に対して検索をかけ、結果を抽出することが可能。

実演用ファイル(1)
zanpakuto.txt
厳霊丸
五形頭
侘助
凍雲
飛梅
蛇尾丸
実演用ファイル(2)
zanpakuto_eng.txt
Gonryoumaru
Gegetsuburi
Wabisuke
Itegumo
Tobiume
Zabimaru

ファイルから、ある文字を含む行のみを抽出する

find "検索したい文字列" 検索対象ファイル名`
例:find "丸" zanpakuto.txt

コマンド実行結果
---------- zanpakuto.txt
厳霊丸
蛇尾丸

ファイルから、ある文字を含まない行のみを抽出する

find /v "丸" zanpakuto.txt

コマンド実行結果
---------- zanpakuto.txt
五形頭
侘助
凍雲
飛梅

抽出した結果に、抽出元における行番号をつける

find /n "丸" zanpakuto.txt

コマンド実行結果
---------- zanpakuto.txt
[1]厳霊丸
[6]蛇尾丸

ファイルから、大文字小文字の区別なく抽出する

find /n /i "I" zanpakuto_eng.txt

コマンド実行結果
---------- zanpakuto_eng.txt
[2]Gegetsuburi
[3]Wabisuke
[4]Itegumo
[5]Tobiume
[6]Zabimaru
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?