Linux中shell脚本基础

输入--0

标准输出--1

错误输出--2

          输出的标志 > ,>是覆盖,>>是在原内容上追加

          输入的标志<,<<<是单行输入,<<是多行输入   通过同样的名字结束,但由于read的特性,所以只能读取一行。

shell变量有五种

本地  name=5

局部  local--只能用于函数

环境  export

特殊

   $$

    $#--获取参数的个数

    $*---获取某一位置的参数($1,$2..)

    $@---等同于$*

    $?----输出上一条指令的执行状态,0为正确  其余全为错

     $BASHPID--打印当前进程的实际ID

本地   使用{}

运算符

     1.算术运算符  let

        C=$(($A+$B))

        C=`expr $A + $B`

        C=$[$A+$B]

     2.逻辑运算符  test

         [ expression ]

         [[ expression ]]

控制循环

    1.for

      for name in 1 2 3

       do

           commands

       done

       for((i=1;i<=5;i++))              死循环        for((;;))

      do                                                           do

            commands                                        commands

       done                                                        done

       2.while

       while  commands              死循环   while ((1))

       do                                             do

           commands                                commands

       done                                       done

      3.dowhile

       4. switch...case

        case name in

         1)

           commands

       ;;

          2)

             commands

        ;;

....

   esac

          5.if

          if commands

           then

                 commands

           elif commands

             then

                     commands

            else

                  commands

         fi

         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值