#author("2019-03-02T15:18:41+00:00","default:haikikyou","haikikyou")
#author("2019-03-17T09:16:36+00:00","default:haikikyou","haikikyou")
[[Windows/コマンドプロンプト/コマンド]]

#contents


* 内容 [#z4458f47]

- ディレクトリを作成する。
- 再帰的にディレクトリを作成できる。
テキスト文字列を検索する。

* 使用方法 [#va7bca1f]

#geshi(bash){{{
md [<Drive>:]<Path>
mkdir [<Drive>:]<Path>
find [/v] [/c] [/n] [/i] [/off[line]] "<String>"
     [[<Drive>:][<Path>]<FileName>[...]]
}}}

** オプション [#o5feb24f]

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

* 使用例 [#q8d40818]

** ディレクトリを作成する [#ffc21694]
** 指定した文字列を含む行を表示する [#g5637cdb]


#geshi(dos){{{
C:\Users\Administrator\dos>md parent\child
c:\test>type file1.txt | find "hello"
"hello"
"hello"

C:\Users\Administrator\dos>dir /s parent
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は 0A12-47B4 です
c:\test>find "hello" file1.txt

 C:\Users\Administrator\dos\parent のディレクトリ
---------- FILE1.TXT
"hello"
"hello"

2019/03/02  14:12    <DIR>          .
2019/03/02  14:12    <DIR>          ..
2019/03/02  14:12    <DIR>          child
               0 個のファイル                   0 バイト
}}}

 C:\Users\Administrator\dos\parent\child のディレクトリ
ワイルドカードやforコマンドと組み合わせて使ってみる。

2019/03/02  14:12    <DIR>          .
2019/03/02  14:12    <DIR>          ..
               0 個のファイル                   0 バイト
#geshi(bash){{{
c:\test>find /n "hello" *.txt

     ファイルの総数:
               0 個のファイル                   0 バイト
               5 個のディレクトリ  296,915,824,640 バイトの空き領域
---------- 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

}}}
** 指定した文字列を含む行番号や行数を表示する [#l7f255e5]


#geshi(dos){{{
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

}}}

* 参考リンク [#ye6e9472]

- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find



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