[linux-l] Gibt's sowas wie Variablen-Expansion in bash?
Achim Pabel
Achim.Pabel at gmx.de
Mo Dez 1 15:29:22 CET 2008
Hi Axel,
versuche mal:
---------------------------------------------
#! /bin/bash
DEF1_S1=VAL1_S1
DEF1_S2=VAL1_S2
DEF1_S3=VAL1_S3
DEF1_S4=VAL1_S4
DEF1_S5=VAL1_S5
line="*******************************\n"
#############################
echo "Ausgabe 1 :: bash :: echo (Variablentest) "
echo "S1: DEF1_S1 = $DEF1_S1"
echo "S2: DEF1_S2 = $DEF1_S2"
echo "S3: DEF1_S3 = $DEF1_S3"
echo "S4: DEF1_S4 = $DEF1_S4"
echo "S5: DEF1_S5 = $DEF1_S5"
echo -e $line
#############################
echo "Ausgabe 2 :: bash :: for"
for echoline in \
"S1: DEF1_S1 = $DEF1_S1" \
"S2: DEF1_S2 = $DEF1_S2" \
"S3: DEF1_S3 = $DEF1_S3" \
"S4: DEF1_S4 = $DEF1_S4" \
"S5: DEF1_S5 = $DEF1_S5"
do
echo $echoline
done
unset echoline
echo -e $line
#############################
echo "Ausgabe 2 :: bash :: eval "
i=1; echoline='$DEF1_S'${i}; eval echoline=$echoline
while [ $echoline ]; do
echo "S${i}: DEF1_S${i} = $echoline"
((i++)); echoline='$DEF1_S'${i}; eval echoline=$echoline
done
unset echoline
echo -e $line
#############################
#EOF
-----------------------------------
Solltes Du ein Perl-Script benötigen (im schlimmstenfalls awk) dann sag
bescheid.
Gruß Achim
Mehr Informationen über die Mailingliste linux-l