Mailinglist Archive: opensuse-de (4938 mails)

< Previous Next >
RE: Problem mit sed/regex;;
  • From: David@xxxxxxxxxx (David Haller)
  • Date: Wed May 24 05:31:38 2000
  • Message-id: <XFMail.000524073138.David@xxxxxxxxxx>



Hallo nochmal,

David Haller wrote:
VAR1=marc
VAR2=dh/bin
# VAR2=dh

if echo $VAR2 | grep /; then
VARTMP=`echo "$VAR2" | sed s/"\/"/'\\\\'"\/"/`
else
VARTMP="$VAR2"
fi

# echo "\$VARTMP=$VARTMP"

VAR3=`echo /home/marc/test.sh | sed s/$VAR1/$VAR3/`
echo "\$VAR3=$VAR3"
unset VARTMP

Ich merke gerade, obiges ist nicht ganz korrekt (und geht kuerzer)
und, um gleich ein paar Varianten zu testen, eine for-Schleife:

==== schnipp ====

VAR1=marc

for VAR2 in "dh" "dh/bin" "dh/temp/test/bin"; do
VARTMP=`echo "$VAR2" | sed s/"\/"/'\\\\'"\/"/g`
VAR3=`echo /home/marc/test.sh | sed s/$VAR1/$VARTMP/`
echo "\$VAR3 = $VAR3"
done
unset VARTMP

==== schnapp ====

CU
David


--
Who can possibly rule, if no one who wants to do it, can be allowed to?
--- Douglas Adams, Hitchhiker's Guide to the Galaxy

email: David@xxxxxxxxxx www: www.dhaller.de

---------------------------------------------------------------------
To unsubscribe, e-mail: suse-linux-unsubscribe@xxxxxxxx
For additional commands, e-mail: suse-linux-help@xxxxxxxx


< Previous Next >
Follow Ups
References