2010-05-29 13 views

Répondre

1

Ceci est probablement aussi proche que vous pouvez obtenir:

#!/bin/sh 
x1="a1 a2" 
x2="b1 b2" 

set -- "$x1" "$x2" 

for x in "[email protected]" 
do 
    # echo $x 
    echo "[${x}]" # proves that the lines are being printed separately 
done 

Sortie:

[a1 a2] 
[b1 b2] 

Dans Bash, vous pouvez utiliser un tableau:

#!/bin/bash 
x1="a1 a2" 
x2="b1 b2" 

list=("$x1" "$x2") 

for x in "${list[@]}" 
do 
    # echo $x 
    echo "[${x}]" # proves that the lines are being printed separately 
done 

sortie même.

0

Ce n'est pas possible dans un shell POSIX standard.

+0

Comme $ @ fait ce que je veux, j'espérais que ce serait possible – dandu