加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Shell脚本中‘‘ () {} [] " " [[]] ``的不同用法

发布时间:2020-12-16 01:54:57 所属栏目:安全 来源:网络整理
导读:[[]]在脚本的使用中作用一是来匹配扩展正则表达式用法[[ =~ ]]例如: [[email?protected] data]# touch f1.sh [[email?protected] data]# file=f1.sh ;[[ $file =~ .sh$ ]] [[email?protected] data]# echo $? 0 [[email?protected] data]# file=f1.shsh ;[
  • [[]]在脚本的使用中作用一是来匹配扩展正则表达式用法[[ =~ ]]例如:

    [[email?protected] data]# touch f1.sh
    [[email?protected] data]# file=f1.sh ;[[ $file =~ .sh$ ]]
    [[email?protected] data]# echo $?
    0
    [[email?protected] data]# file=f1.shsh ;[[ $file =~ .sh$ ]]
    [[email?protected] data]# echo $?
    1

  • [[]]在脚本中的作用二是来匹配通配符用法:[[ == ]]或[[ != ]]例如:

    [[email?protected] script]# file=f1.shsh
    [[email?protected] script]# [[ "$file" == f ]]
    [[email?protected] script]# echo $?
    0
    [[email?protected] script]# [[ "$file" == fx
    ]]
    [[email?protected] script]# echo $?
    1

  • echo $_表示上一个命令的最后一个参数。
  • Shell脚本中()的作用为将里面的命令在子shell里面执行,执行完毕之后退出

    [[email?protected] script]# ( u=1;sleep 1000 )

  • 查看进程图

    与之相反的是{;}只是在当前shell中执行。

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读