You are not logged in.

#1 2009-01-21 20:43:57

big_gie
Member
Registered: 2005-01-19
Posts: 637

[SOVLED] Bash: substring removal question

I'm pulling my hair off this one...

I want to extract a substring from a variable in bash. It works fine all the time EXCEPT when the resulting string consist of only any number of "e" letters...

$ pkgname=kernel26-custom
$ echo ${pkgname#kernel26}
-custom
$ pkgname=kernel26-e
$ echo ${pkgname#kernel26}
 (nothing)
$ pkgname=kernel26-ee
$ echo ${pkgname#kernel26}
 (nothing)
$ pkgname=kernel26-eee
$ echo ${pkgname#kernel26}
 (nothing)
$ pkgname=kernel26-eeee
$ echo ${pkgname#kernel26}
 (nothing)
$ pkgname=kernel26eee
$ echo ${pkgname#kernel26}
eee

How come it does not work? What am I doing wrong? What is the rule for that? How can I extract "-eee" from the variable?

Thanx wink

Last edited by big_gie (2009-01-21 20:46:47)

Offline

#2 2009-01-21 20:46:27

big_gie
Member
Registered: 2005-01-19
Posts: 637

Re: [SOVLED] Bash: substring removal question

Never mind... I have my answer... (thanx phrakture wink

"-e" is an echo flag... This works work (note the space):

$ pkgname=kernel26-eeee
$ echo " ${pkgname#kernel26}"
-eee

Offline

Board footer

Powered by FluxBB