Hallo, On Mon, 18 Feb 2002, Ralph Müller wrote:
Bernd Brodesser wrote:
* Harry Rüter schrieb am 17.Feb.2002:
Der Knackpunkt ist dem find den Parameter "*.xyz" unterzuschieben. Ich hab's jetzt in tausend Varianten probiert und es hat bisher nicht funktioniert.
Also es sollte dann folgendes dastehen:
find . -name '*.xyz' -exec ... Hier muß dann was mit $3 stehen ^^^
find . -name "$3" funktioniert nicht? Achso, der * Dann vorher noch ein name = "'*'$3" und dann find . -name "$name"
Habe ich jetzt aber auch nicht ausprobiert. Vielleicht funktioniert auch find . -name "*$3"
Wäre das nicht vielleicht ein Anwendungsfall für den Befehl "eval"? Dann läuft die Bash _2x_ über den Ausdruck...
Also hier geht's (bash 2.04). ,----[ /tmp/test/find.sh ] | #! /bin/bash | # USAGE: find.sh "PFAD" "PATTERN" "REPLACEMENT" "FILEPATTERN" | # all arguments MUST be quoted! | sedexpr="s/$2/$3/g" | find "$1" -name "$4" -exec /tmp/test/sed.sh "$sedexpr" {} \; `---- ,----[ /tmp/test/sed.sh ] | #!/bin/sh | expr="$1"; shift; | OLDIFS="$IFS" | IFS=" | " | for file in $@ | do | cp -i "${file}" "${file}.bak" | sed "$expr" < "${file}.bak" > "${file}" \ | || mv "${file}.bak" "${file}" | done | IFS="$OLDIFS" `---- z.B: /tmp/test/find.sh /tmp/test/ "#inlcude" "#include" "*.c" Obiges bedingt Dateinamen ohne Zeilenumbruch ('\n') im Namen, Leerzeichen sind ok (man achte auf das durchaengige quoten). -dnh -- Sex in tv programs, and the "monkey see, monkey do" principle. In other words if on-screen violence switched from exotic machines guns to everyday items found around the household, America's average IQ would rise. -- Chris Hacking in asr. about luser reproduction