Windows/コマンドプロンプト/コマンド

内容

テキスト文字列を検索する。

使用方法

find [/v] [/c] [/n] [/i] [/off[line]] "<String>"
     [[<Drive>:][<Path>]<FileName>[...]]

オプション

オプション説明
/v否定、指定した文字列を含まない行を表示する。
/c指定した文字列を含む行の数だけを表示する。
/n行番号を表示する。
/i大文字と小文字を区別しないで検索する。
/off[line]オフライン属性が指定されたファイルをスキップしない。
"<String>"検索文字列
<FileName>検索するファイル

使用例

指定した文字列を含む行を表示する

c:\test>type file1.txt | find "hello"
"hello"
"hello"

c:\test>find "hello" file1.txt

---------- FILE1.TXT
"hello"
"hello"
 

ワイルドカードやforコマンドと組み合わせて使ってみる。

c:\test>find /n "hello" *.txt

---------- FILE1.TXT
[1]"hello"
[3]"hello"

---------- HELLO-WORLD.TXT
[1]"hello"
[3]"hello"

---------- HELLO.TXT
[1]"hello"

---------- WORLD.TXT

c:\test>for %f in (*.txt) do find "hello" %f

c:\test>find "hello" file1.txt

---------- FILE1.TXT
"hello"
"hello"

c:\test>find "hello" hello-world.txt

---------- HELLO-WORLD.TXT
"hello"
"hello"

c:\test>find "hello" hello.txt

---------- HELLO.TXT
"hello"

c:\test>find "hello" world.txt

---------- WORLD.TXT
 

指定した文字列を含む行番号や行数を表示する

c:\test>type file1.txt
"hello"
"world"
"hello"
"world"

c:\test>find /n "hello" file1.txt

---------- FILE1.TXT
[1]"hello"
[3]"hello"

c:\test>find /c "hello" file1.txt

---------- FILE1.TXT: 2
 

参考リンク


トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP