meinereinerseiner
31-03-2005, 10:35
moins,
ich versuche einen string mit awk zu zerlegen, das geht auch alles solange
bis ich es von einer for-schleife machen lassen will:
#!/bin/sh
#
zeile="timeperiod[btime]=Plan B Loesung 2;;01:00-09:00;01:00-09:00;01:00-09:00;01:00-09:00;01:00-09:00;;"
PART1=`echo "$zeile" | awk -F\; '{print $1}'`
for (( i=2; $i <= 8; i++ )); do
PART$i=`echo "$zeile" | awk -F\; '{print $i}' i=$i`
done
# testausgabe
echo "$PART1;$PART2;$PART3;$PART4;$PART5;$PART6;$PART7;$ PART8"
das ist nicht das ganze script, nur ein auszug mit der problemstelle.
als testausgabe sollte eigentlich das selbe wie in $zeile rauskommen,
statt dessen bekomme ich nur:
./plepps2.sh: PART2=: command not found
./plepps2.sh: PART3=01:00-09:00: command not found
./plepps2.sh: PART4=01:00-09:00: command not found
./plepps2.sh: PART5=01:00-09:00: command not found
./plepps2.sh: PART6=01:00-09:00: command not found
./plepps2.sh: PART7=01:00-09:00: command not found
./plepps2.sh: PART8=: command not found
timeperiod[btime]=Plan B Loesung 2;;;;;;;
wo ist denn da nun wieder mein denkfehler - kann ja nur an der
verarbeitung von $i liegen.....
thx
der tom
ich versuche einen string mit awk zu zerlegen, das geht auch alles solange
bis ich es von einer for-schleife machen lassen will:
#!/bin/sh
#
zeile="timeperiod[btime]=Plan B Loesung 2;;01:00-09:00;01:00-09:00;01:00-09:00;01:00-09:00;01:00-09:00;;"
PART1=`echo "$zeile" | awk -F\; '{print $1}'`
for (( i=2; $i <= 8; i++ )); do
PART$i=`echo "$zeile" | awk -F\; '{print $i}' i=$i`
done
# testausgabe
echo "$PART1;$PART2;$PART3;$PART4;$PART5;$PART6;$PART7;$ PART8"
das ist nicht das ganze script, nur ein auszug mit der problemstelle.
als testausgabe sollte eigentlich das selbe wie in $zeile rauskommen,
statt dessen bekomme ich nur:
./plepps2.sh: PART2=: command not found
./plepps2.sh: PART3=01:00-09:00: command not found
./plepps2.sh: PART4=01:00-09:00: command not found
./plepps2.sh: PART5=01:00-09:00: command not found
./plepps2.sh: PART6=01:00-09:00: command not found
./plepps2.sh: PART7=01:00-09:00: command not found
./plepps2.sh: PART8=: command not found
timeperiod[btime]=Plan B Loesung 2;;;;;;;
wo ist denn da nun wieder mein denkfehler - kann ja nur an der
verarbeitung von $i liegen.....
thx
der tom