zoukankan      html  css  js  c++  java
  • linux中$与()的一点使用疑惑解释

    a=$(cat 1.sh)
    等价于
    a=`cat 1.sh`


    a=(cat 1.sh) 相当于定义一个a数组,内容为cat 1.sh
    a=(`cat 1.sh`)相当于把1.sh里面的内容当成a的数组,a仍旧是一个数组
    a=$(`cat 1.sh`)此命令会报错,不能执行

    [root@zejin240 chenzejin]# cat 1.sh 
    hello world 2016
    better
    [root@zejin240 chenzejin]# a=(cat 1.sh) [root@zejin240 chenzejin]# b=(`cat 1.sh`) [root@zejin240 chenzejin]# c=$(cat 1.sh) [root@zejin240 chenzejin]# d=`cat 1.sh`

    [root@zejin240 chenzejin]# echo ${a[@]} cat 1.sh [root@zejin240 chenzejin]# echo ${b[@]} hello world 2016 better [root@zejin240 chenzejin]# echo ${c[@]} hello world 2016 better [root@zejin240 chenzejin]# echo ${d[@]} hello world 2016 better
    [root@zejin240 chenzejin]#
    echo $a cat [root@zejin240 chenzejin]# echo $b hello [root@zejin240 chenzejin]# echo $c hello world 2016 better [root@zejin240 chenzejin]# echo $d hello world 2016 better

    [root@zejin240 chenzejin]# e=$(`cat 1.sh`)
    -bash: hello: command not found
  • 相关阅读:
    CVE-2019-0708
    windows powershell的常用命令
    sqli-lab(8)
    DVWA--CSP Bypass
    认清自己
    sqli-libs(7)
    DVWA--upload
    sqli-labs(6)
    python学习之路(22)
    BZOJ2434:[NOI2011]阿狸的打字机——题解
  • 原文地址:https://www.cnblogs.com/zejin2008/p/5132273.html
Copyright © 2011-2022 走看看