shellスクリプト学習ノート


前言
bashに基づいて、そして野菜と鳥の教程のshell教程を参考にします。http://www.runoob.com/linux/linux-shell.html
### shell      
chmod +x ./test.sh  
bash test.sh
入出力
デバッグ出力
#!/bin/bash
set -x
外部パラメータ
#!/bin/bash
# author:    
# url:www.runoob.com
echo "Shell       !";  ## echo      
echo "      :$0";
echo "      :$1";
echo "      :$2";
echo "      :$3";

$ chmod +x test.sh 
$ ./test.sh 1 2 3
Shell       !
      :./test.sh
      :1
      :2
      :3
printfフォーマット出力
#!/bin/bash
# author:    
# url:www.runoob.com

printf "%-10s %-8s %-4s
" kg printf "%-10s %-8s %-4.2f
" 66.1234 printf "%-10s %-8s %-4.2f
" 48.6543 printf "%-10s %-8s %-4.2f
" 47.9876
詳しくはhttp://www.runoob.com/linux/linux-shell-printf.html
リダイレクト
         ,             。

command > file
command < file
command >> file

            0        (STDIN),1      (STDOUT),2        (STDERR)。

command 2 > file   ##      file
command > file 2>&1     ##             file
command > /dev/null 2>&1  ##        
外部ファイル
. filename   #     (.)          
 
source filename
変数と割り当て
   http://www.runoob.com/linux/linux-shell-variable.html
演算
  、  (  )、  (   )、  (  )、   、    
http://www.runoob.com/linux/linux-shell-basic-operators.html 
  
https://www.cnblogs.com/hanxiaoyu/p/5759477.html
行列
  :http://www.runoob.com/linux/linux-shell-array.html
フロー制御
  :http://www.runoob.com/linux/linux-shell-process-control.html
関数
  :http://www.runoob.com/linux/linux-shell-func.html
常用システムコマンド
http://www.runoob.com/linux/linux-command-manual.htmlsed、tail、grep、wc、awk、more、cat
ステップを適用
ユーザーインタラクションreadhttp://www.runoob.com/linux/linux-comm-read.htmlグラフィック・インタラクションdialoghttp://www.ttlsa.com/linux-command/linux-dialog-shell/自動インタラクティブexpecthttp://www.cnblogs.com/lixigang/articles/4849527.html