subshell

    2熱度

    1回答

    在script.sh, source a.sh source b.sh CMD1 CMD2 CMD3 我怎能取代source *.sh與他們的內容(不執行命令)? 我想知道在找到文件並擴展所有變量之後,bash解釋器執行的是什麼。 我知道我可以使用set -n -v或運行bash -n -v script.sh 2>output.sh,但這不會替代源命令(如果a.sh或b.sh包含變

    1熱度

    1回答

    我寫以下代碼: case "$2" in '+') ((res = $1 + $2));; '-') ((res = $1 - $2));; esac echo $res 用例:./"*filename*" 2 + 3 如果使用雙括號, ((res = $1 + $2)) 則結果被打印。但是,如果我使用單括號 (res = $1 + $2) 然後沒有打印。 ()

    0熱度

    2回答

    的命令時錯誤: (echo: command not found 代碼: input="(echo 1)" $input 爲什麼它不評估括號以同樣的方式,把它放在當我這樣稱呼它的時候是一個子殼?

    0熱度

    1回答

    所以這裏是我的問題,我有我寫這個腳本,我在哪裏出口兩個變量,但他們沒有把它變成子殼。 該腳本的目的是爲CentOS和Ubuntu主機更改用戶密碼並清除它們的pam_tally。 有一點背景是,這個環境的用戶是由puppet管理的,但密碼都是本地的,ssh密鑰也是不允許的(這是設置在石頭上,不能改變,所以我必須與我得到的東西一起工作),原因是每次登錄都必須是手動的(甚至會話數限制爲兩個,所以你甚至不

    0熱度

    1回答

    基本上,我試圖退出包含循環的子殼。這裏是代碼: ` stop=0 ( # subshell start while true # Loop start do sleep 1 # Wait a second echo 1 >> /tmp/output # Add a line to a test file if [ $stop

    2熱度

    1回答

    此命令按預期工作: (dpkg -l | egrep "linux.+3.8.0.*44" | awk '{print $2}') linux-generic-lts-raring linux-headers-3.8.0-44 linux-headers-3.8.0-44-generic linux-headers-generic-lts-raring linux-image-3.8.0

    0熱度

    2回答

    我希望有人可以幫助將db2命令的輸出應用於一個變量,以便稍後在腳本中使用。 到目前爲止,我在... db2 "connect to <database> user <username> using <password>" while read HowMany ; do Counter=$HowMany echo $HowMany done < <(db2 -x "SEL

    0熱度

    1回答

    這個腳本外殼適用於GNU/Linux的罰款,但沒有對AIX 5.3 #!/bin/sh echo $SHELL set -o nounset -o errexit [ 1 -eq 1 ] && { echo "zzz" } && echo "aaa" && [ 1 -eq 0 ] && echo "bbb" echo "ccc" 在GNU/Linux的意外行爲,我已經

    0熱度

    2回答

    bash shell腳本可以將給定的字符串按空間拆分爲1D數組。 str="a b c d e" arr=($str) # arr[0] is a, arr[1] is b, etc. arr is now an array, but what is the magic behind? 但是,究竟發生了什麼,當我們可以arr=($str)?我的理解是這裏的括號創建了一個子shell,但之

    0熱度

    1回答

    如何在bash子shell中調用echo?這是行爲我想: # w=5 # echo $w > /tmp/x # cat /tmp/x 5 但是: # cmd="echo $w > /tmp/x" # $cmd 5 > /tmp/x 和: # $($cmd) bash: 5: command not found