linux shell脚本 传参,在bash shell脚本中传播所有参数
我知道這個問題已經(jīng)得到很好的回答,但這是“ $ @” $ @“ $ *”和$ *之間的比較
測試腳本的內(nèi)容:
# cat ./test.sh
#!/usr/bin/env bash
echo "================================="
echo "Quoted DOLLAR-AT"
for ARG in "$@"; do
echo $ARG
done
echo "================================="
echo "NOT Quoted DOLLAR-AT"
for ARG in $@; do
echo $ARG
done
echo "================================="
echo "Quoted DOLLAR-STAR"
for ARG in "$*"; do
echo $ARG
done
echo "================================="
echo "NOT Quoted DOLLAR-STAR"
for ARG in $*; do
echo $ARG
done
echo "================================="
現(xiàn)在,使用各種參數(shù)運行測試腳本:
# ./test.sh? "arg with space one" "arg2" arg3
=================================
Quoted DOLLAR-AT
arg with space one
arg2
arg3
=================================
NOT Quoted DOLLAR-AT
arg
with
space
one
arg2
arg3
=================================
Quoted DOLLAR-STAR
arg with space one arg2 arg3
=================================
NOT Quoted DOLLAR-STAR
arg
with
space
one
arg2
arg3
=================================
總結(jié)
以上是生活随笔為你收集整理的linux shell脚本 传参,在bash shell脚本中传播所有参数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么查询linux中的组密码,linux
- 下一篇: linux vnc用户,给CentOS服