この記事について
| 環境 | Windows、コマンドプロンプト |
|---|---|
| 目的 | dirコマンドの結果を正規表現で絞り込む |
| 結果 | |(パイプ)でfindstrに渡す。findstrは正規表現が使える |
dirコマンドで正規表現を使うには |(パイプ)と findstr を用いる。
//例:数字だけのディレクトリ名だけ抽出
dir /ad | findstr "¥<[0-9]*¥>"
dir /ad → ディレクトリだけ抽出
|(パイプ) → dir の結果を findstr に渡す
findstr → 正規表現が利用できる
¥< → 単語の先頭
¥> → 単語の末尾
findstr の正規表現について詳しくはこちら
http://www.atmarkit.co.jp/ait/articles/0412/18/news018.html
