Bash: not evaluating variable correctly

时间:2015-05-08 09:59:58

标签: bash loops variables

I have a simple bash function which includes a loop to capture hostnames for x number of times (defined in $number_of_hosts):

<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>

If I echo out each variable individually they work. For example

awk '{$0=substr($0,47)}/^S\|/{x=1}/\^M$/{x=0}x' file

S|aaaaa|bbbbb|32|D|M|28/04/2015|ccc|33208369
.05|28/04/2015|0428|C|105840.|dddd|fffff|9511705558|/CTC/097/eeeeee eee|/PT
/SC/TT/12/SN/eee eeeeeee/CeeY/ee -eee aa aaaa S.A.B. DE C.V./DC/aaaaa
 AND aaaaa aaaa/NA/aaaaa,/SK/aaaaa|D|M|28/04/2015|MXN|11111.17||||
||||ssssss|ssssss|qwerrt-aaaaaa|ggggggg||||||||||||||||

However, if I try to add another for loop around that (used in a later function), I can't seem to get it to work. I am using

number_of_hosts="3"

for i in $(seq 1 $number_of_hosts); do 
    read -ep "enter hostname" host$i
done

How can I successfully echo the values that were captured by 'read' earlier?

Thank you in advance for your help.

0 个答案:

没有答案