Veröffentlicht 23. Februar 200619 j Hi, kleines Problem: /bin/sed -n -e "s/\(^[a-zA-Z]*\):$VAR:N$/\1/gp" /etc/test funtkioniert nicht -> Unknown option to `s' Wie kann ich eine Env Variable einfügen? Beim googeln hatten die alle ' statt ". Das ist bei mir nicht der Fall. Gruß Scratch
23. Februar 200619 j Mit single-quotes dürfte es auch nicht gehen, weil dann die Variablen nicht von der shell expandiert werden. Ich kann den Fehler jedoch nicht nachvollziehen. sed-Version? Wie sieht /etc/test aus und was willst du Substituieren? Was ist der Wert deiner Variable? user@host:~> cat testfile.txt foo:bar blubb:omg k:thxbye bar:foo user@host:~> VALUE=omg; sed -e 's/^\([a-zA-Z]*\):$VALUE$/\1/g' testfile.txt foo:bar blubb:omg k:thxbye bar:foo Single-Quotes tun nicht, weil hier nach $VALUE gesucht wird, nicht nach dem Inhalt der Variable VALUE user@host:~> VALUE=omg; sed -e "s/^\([a-zA-Z]*\):$VALUE$/\1/g" testfile.txt foo:bar blubb k:thxbye bar:foo Tut, weil hier die Shell $VALUE erst auswerted und dann an sed gibt.
23. Februar 200619 j Autor Hi, der Befehl lautet genau: /bin/sed -n -e "s/^\([a-zA-Z]*\):$ORACLE\_HOME:N/\1/gp" /etc/oratab die sed Version ist: 4.0.7 # echo $ORACLE_HOME /opt/app/oracle/product/inf904 /etc/oratab *:/opt/app/oracle/product/inf904:N iasdb:/opt/app/oracle/product/inf904:N Der Fehler ist: /bin/sed: -e expression #1, char 23: Unknown option to `s' Gruß Scratch
23. Februar 200619 j ... Natürlich geht das nicht Der Wert deiner Variable enthält Slashes. Die musst du schon escapen, weil sie sonst sed interpretiert. Mit ORACLE_HOME=/opt/app/oracle/product/inf904 wird aus deinem Command: /bin/sed -n -e "s/^\([a-zA-Z]*\):/opt/app/oracle/product/inf904:N/\1/gp" /etc/oratab und das sind ein paar zuviel /// für sed. Weich auf alternative Trenner aus oder escape die /'s im OraPath durch \/
24. Februar 200619 j Autor Ok daran hatte ich garnicht gedacht :bimei :bimei So gehts ... http://www.unet.univie.ac.at/aix/cmds/aixcmds5/sed.htm You can select the character delimiter for patterns. The general form of the expression is: \?pattern? where ? (question ... /bin/sed -n -e "s?^\([a-zA-Z]*\):$ORACLE_HOME:[NY]?\1?gp" /etc/oratab Danke! Gruß Scratch
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.