Answer the question
In order to leave comments, you need to log in
How to make bash process more than 9 variables?
I have a problem, I can’t understand how to solve
in the first option, all variables are processed normally
[email protected]:/etc/cron_user# ./test.sh y1 y2.ru y3.ru y4.ru y5.ru y6.ru y7.ru y8. ru y9.ru y10.ru
y1 y2.ru y3.ru y4.ru y5.ru y6.ru y7.ru y8.ru y9.ru y10
in the second $1 is confused with $10 because of the dot in the value and is treated as $1+ "0"
[email protected]:/etc/cron_user# ./test.sh y1.ru y2.ru y3.ru y4.ru y5.ru y6.ru y7.ru y8.ru y9.ru y10.ru
y1.ru y2.ru y3.ru y4.ru y5.ru y6.ru y7.ru y8.ru y9.ru y1.ru0
simple code
[email protected]:/etc/cron_user# cat test.sh
#!/bin/bash
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
[email protected]:/etc/cron_user#
Answer the question
In order to leave comments, you need to log in
You can use shift, works with any number of arguments:
#!/bin/bash
while (( "$#" )); do
echo -n "$1 "
shift
done
echo
Always take variables in ${ } - this saves a lot of these errors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question