2015年7月6日

windows上等同 cat 及 grep 的指令

linux 的 cat 及 grep 指令在查找紀錄檔時相當好用,windows系統上也有類似的指令,分別是 type、find 及 findstr,指令的詳細用法可以用 help command 取得說明

顯示檔案內容
cmd> type _vimrc
 set nocompatible
 behave mswin
 set nobackup
 set tabstop=4
 colorscheme koehler

搜尋輸出的資訊,例如查找系統在監聽的通訊埠
cmd> netstat -an | find "LISTEN"
  TCP    0.0.0.0:135             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:4000           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING

那兩個指令的結合就是等同 cat 及 grep
cmd> type file | find "pattern"

沒有留言:

張貼留言