2
我試圖傳入參數並將其打印出來。我不能。如何在處理|時通過+讀取參數(管)?
嘗試#1
curl www.site.com/bash/bashrc.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3391 100 3391 0 0 66809 0 --:--:-- --:--:-- --:--:-- 67820
There 0 arguments
嘗試#2
curl www.site.com/bash/bashrc.sh | bash yellow red green
bash: yellow: No such file or directory
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3391 100 3391 0 0 130k 0 --:--:-- --:--:-- --:--:-- 132k
(23) Failed writing body
我的目標是能夠訪問我的論點,我在我的腳本中傳遞:yellow
,red
,
[0]:的bash
[1]:黃色
[2]:紅色
[3]:綠色
bashrc.sh
#!/bin/bash
for i in [email protected]
do echo $i
done
echo "There $# arguments"
....
我該如何達到目標?