View previous topic :: View next topic |
Author |
Message |
zouk Tux's lil' helper


Joined: 09 Mar 2004 Posts: 114
|
Posted: Thu Jun 10, 2004 12:24 pm Post subject: [OT] Bashscript: Strings durch Pipe zusammensetzen |
|
|
Ich hab folgendes Problem: ich lasse mit 'find' mir alle Unterverzeichnisse eines Pfades ausgeben und pipe dass in ein 'awk' welches mir einen bestimmten vorderen Teil abschneiden und durch einen anderen ersetzen soll.
Code: | find $1 -type d -print | awk -F\$localRootDir '{ print $2 }' |
Jetzt kann ich ja nicht einfach das benötigte
Code: | find $1 -type d -print | awk -F\$localRootDir '{ print $variable $2 }' |
schreiben (bzw {print "$variable" $2}). awk kennt die Bash-Variable $variable nicht. Hat jemand eine Idee wie ich trotzdem zu meinem gewünschten Ziel komme?
Vielen Dank schonmal,
zouk |
|
Back to top |
|
 |
Fibbs Guru


Joined: 26 Jan 2003 Posts: 448 Location: Forstern near Munich / Germany
|
Posted: Thu Jun 10, 2004 12:34 pm Post subject: |
|
|
Hmm, also entweder ich habe Deine Frage nicht richtig verstanden, oder sed ist ganz genau das, was Du eigentlich willst.
Code: |
find $1 -type d -print | sed 's/$localRootDir/$variable/'
|
Gruß,
Fibbs |
|
Back to top |
|
 |
Earthwings Bodhisattva


Joined: 14 Apr 2003 Posts: 7753 Location: Germany
|
Posted: Thu Jun 10, 2004 12:44 pm Post subject: |
|
|
Für die meisten Fälle reicht bereits das, was die bash anbietet. Hier z.B. ${string/substring/replacement} |
|
Back to top |
|
 |
Fibbs Guru


Joined: 26 Jan 2003 Posts: 448 Location: Forstern near Munich / Germany
|
Posted: Thu Jun 10, 2004 2:26 pm Post subject: |
|
|
hey, das wusste ich noch gar nicht *schäm*...
Danke für den Hinweis |
|
Back to top |
|
 |
|