meta data for this page
  •  

差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
coding:bash [2019/04/02 10:16]
ghsrobert 繼續學
coding:bash [2019/04/05 22:31] (目前版本)
ghsrobert 欲學迴圈未果
行 11: 行 11:
   * 字串可以用 ''%%'%%'' 括住 ← 只會留一個空格   * 字串可以用 ''%%'%%'' 括住 ← 只會留一個空格
     * ''"..."'' 可以保留任何空格字元     * ''"..."'' 可以保留任何空格字元
 +  * 註解:行首或行中 ''# ''((更深入介紹各種方法:[[https://stackoverflow.com/questions/1455988/commenting-in-a-bash-script|syntax - Commenting in a Bash script - Stack Overflow]]))
  
 ==== 變數 ==== ==== 變數 ====
   * case-sensitive   * case-sensitive
   * 名稱可含字母、底線   * 名稱可含字母、底線
 +  * 指定值用 ''='',__**但前後不可以有空格!**__/,(我的第一個習作就著了這個道啦……),/
   * 被引用時,名稱前面加 ''$''   * 被引用時,名稱前面加 ''$''
     * 若要把 ''$'' 當一般符號用,就 ''\$'' 避掉     * 若要把 ''$'' 當一般符號用,就 ''\$'' 避掉
行 21: 行 23:
 FileWithTimeStamp=/tmp/my-dir/file_$(/bin/date +%Y-%m-%d).txt</code></div>((摘自 [[https://www.learnshell.org/en/Variables|Variables (learnshell.org)]])) FileWithTimeStamp=/tmp/my-dir/file_$(/bin/date +%Y-%m-%d).txt</code></div>((摘自 [[https://www.learnshell.org/en/Variables|Variables (learnshell.org)]]))
  
-<div tip>【目前進度】[[https://www.learnshell.org/en/Passing_Arguments_to_the_Script|Passing Arguments to the Script - Learn Shell Programming - Free Interactive Shell Programming Tutorial]]</tip>+<div tip>【目前進度】[[https://www.learnshell.org/en/Passing_Arguments_to_the_Script|Passing Arguments to the Script - Learn Shell Programming - Free Interactive Shell Programming Tutorial]]</div> 
 + 
 +==== 迴圈 ==== 
 +((20190405 為了實際應用的需要,跳過教程順序,超前學習 XD)) 
 +〔啊,LearnShell.org 的教程只介紹了不同種類 loop 的基本結構,沒有詳細說明啊〕 
 + 
 +==== 執行 ==== 
 +  * 賦予執行權限:<code bash>chmod a+x <腳本檔名></code>(([[https://stackoverflow.com/questions/5125907/how-to-run-a-shell-script-in-os-x-by-double-clicking/5126257|macos - How to run a shell script in OS X by double-clicking? - Stack Overflow]])) 
 +  * 在 macOS 中開啟:選擇用「終端機」
  
 ===== 參考 ===== ===== 參考 =====
   * [[https://www.wikiwand.com/en/Bash_(Unix_shell)|Bash (Unix shell) - Wikiwand]]   * [[https://www.wikiwand.com/en/Bash_(Unix_shell)|Bash (Unix shell) - Wikiwand]]