2011年2月4日 星期五

Windows Command Line

dir usage
  1. dir /b *.java
    • list all files end with .java in current directory in simple format
  2. dir /b/s *.java
    • list all files end with .java in current directory recursively in simple format
for usage
  1. for [/d][/r] %i in (set) do command [command-parameters]
    • %i : variable, case sensitive
    • set : file list. ex : (file.txt file2.txt), (*.txt)
    • /d : similar to 1. but (set) is not file list, is a directory list
    • /r : do same "for work" in every sub directory of current place
  2. for /L %variable in (start,step,end) do command [command-parameters]
    • numerical iteration. ex. (1,1,5) = (1 2 3 4 5), (5,-1,1) = (5 4 3 2 1)

  • FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
  • FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
  • FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
    or add usebackq option in options:
  • FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
  • FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
  • FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]
options is list below
  • eol=c : end of line charactor
  • skip=n : skip n lines
  • delims=xxx : delims charactor list
  • tokens=x,y,m-n : 
    • 指定每一行的哪些文字串應該被傳到 for 的內部以用來進行每一個重複操作。
    • 這會導致額外的變數名稱被配置。
    • m-n 格式代表一個範圍,指定了第 m 個到第 n 個字串項。
    • 如果在 tokens= 字串的最後一個字元是星號,則會配置一個額外的變數來接收最後一個字串項被分析後的其他文字。
  • usebackq 
    • 指定新語義開始作用。
    • `反括號`的字串會被當作命令來執行
    • '單引號'字串是純文字字串
    • 此外還允許使用"雙引號"來引用在 filenameset 內的檔名。
example :
     FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k

%IMPORTENT%
    when using a variable in batch file, the usage is %%v not %v


看書很快樂!!

邊看書邊思考的時候 看的內容真的很容易記起來
=
剛來這裡的時候買的一本Design Pattern的書

三個禮拜了 第一次翻過去 跟第二次邊看邊想 兩種讀法真的有差

而且內容真的有記起來 看的速度也不見得比較慢

這種感覺 雖然不是很容易抓住

不過有查覺到或許可以透過多練習而習慣跟學會這種讀書的樂趣

這個真的是讀書的方法阿 多想可以多增加大腦的連結 而增加記憶的強度 跟能力

加油!! 希望可以持續