George Toft wrote:
Stefan Troeger wrote:
[...]
it should read sed 's#.*\(\.\)#\1#g'
Ciao, Stefan
Could someone translate this to English? I've used sed a little bit, but this intrigues me. So I checked man:
s/regexp/replacement/ Attempt to match regexp against the pattern space. If successful, replace that portion matched with replacement. The replacement may contain the spe cial character & to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-expressions in the regexp.
So if the script begins with "s", then a slash must follow, right?
Actually you can use any character instead of a slash here.
echo foo |sed 's/foo/bar/' echo foo |sed 's@foo@bar@' echo foo |sed 's.foo.bar.' echo foo |sed 's|foo|bar|' echo foo |sed 'spfoopbarp' [...9 OK. I'm 10 points smarter (read Unix Shell Programming about regular expressions). Why did you make the replacement text \1 when . would do? $ echo "./top/001/abcdef.txt" |sed 's#.*\(\.\)#.#g' .txt
You are quite correct, the above is better done with expr though in which case the \(\) are more important:
expr match "./top/001/abcdef.txt" '.*\(\.[^.]*\)$' .txt
/Michael -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/