linux shell 指令好记速查

来源:互联网 发布:matlab 网络仿真 编辑:程序博客网 时间:2024/05/17 01:30

    1.访问变量要加$ 

        a=100

        echo $a

    2.read a #将用户输入内容放入a

    3.参数

        $0 脚本名字,$# 参数个数,$$ shell脚本进程号,$1...$n 具体参数

        $*,$@ 全部参数,前者以$IFS分隔

    4.test或者[]

        if test -f xxx.c;then   #or [ -f xxx.c ]

        ...

        fi

    5.if [cond0] || [cond1] && [cond2];then elif else  fi

    6.for i in ... do ... done

    7.while cond do ... done

    8.until cond do ... done

    9.case val in 

        cond1_a | cond1_b) ...;;

        cond2)...;;

        esac

    10.多个语句 {}

    11.函数 foo() {local xxx = xxx;return xxx}

    12.break,continue,

    13, :号 , true的别名

    14. 符号.在当前shell中执行命令

    15.对参数求值 eval

    16.exec将当前shell换为其他程序

    17.expr将参数作为表达式求值

    18.set|unset为shell设置|删除参数变量

    19.shift将所有参数左移一位

    20.trap信号处理

    21.find [path] [options] [tests] [actions]

    22.$()|``将命令以字符串方式返回

    23.$((...)),${}参数扩展

    24.$?上一命令的退出状态

原创粉丝点击