shellスクリプト学習-基礎知識


一、常用ショートカットキー
    Tab           
     ^c                
     ^z                     
     ^d           
     ^l           
     ^a                    
     ^e                   
     ^u                  
     ^k                  
     ^r               

二、常用ワイルドカード
     *       0       
     ?             
     [list]      []                [a-z]
     [!list]        []          
     {string1,string2,...}     {}             {1..8}
bash    :
        “”             ,  $      
        ‘’             ,       ,shell          
        ``     $()  ,  、       ,     ,        

三、shell基礎知識
     shell  : cat /etc/shells
                        /bin/sh          
                        /bin/bash                shell
                        /sbin/nologin             ,      
                        /bin/dash                    
                        /bin/csh                 C   shell
                        /bin/tcsh              csh   ,  csh
     shell      :
                        #!/bin/bash
                       #!/bin/env    chmod +x shell.sh
                             ./shell.sh             
                bash shell.sh
                          source shell.sh
                             bash +x shell.sh          
                             bash +n shell.sh            

四、変数
            =   
         A=hello              
         echo $A             
         echo ${A}         
         unset A             
          :
          1、           
          2、           # ?@ !
          3、           
          4、         
          5、         
          
      :
          1、 A=1234567
               echo ${A:2:4}              3456               ,        4   
          2、``   $()                
          3、         read
            read [  ]    
                  -p               
                  -n            
                  -s              
                  -t             , 
            read -p "Input your name:" name
            read -s -p "Input your password:" pass
            read -n 5 -p "Input your name:" name       5   
            read -t 3 -p "Input your name:" name         3 
            read -p "Input your ip:" IP < ip.txt              
          4、        (declare)
            declare       =   
                         -i                  declare -i A=123
                         -r                    declare -r B=hello
                         -a         
                         -A         
                         -x               declare -x AAA=123     export AAA=123
         5、         
                  =             (         )
               env               
               set                
               export         
                     :
               /etc/profile           ,      bash
               $HOME/.bash_profile          ,       
               $HOME/.bashrc         bash  ,       
               /etc/bashrc        bash  ,  ,      
               $HOME/.bash_logout           shell    
               source$?                 
               $0                  
               $#                  
               $*                  ,    ,        
               $@                ,    ,    
               $1~$9             
               ${10}~${n}         
               $$              
               $!                           
               !$                    
               

五、四則演算
$((   ))     
     $[  ]     
     expr    
     let
     bc
     i++        ,   
     ++i        ,