PDA

View Full Version : bash script compare variables pattern matching


tombstone
31st May 2006, 19:37
Fairly new to bash scripting and I'm having a hard time wrapping my head around this one.
Lets say I have 2 variables

user and db
db='username_blah'
user='username'

how would I compare those 2 saying
if user=beginning of db(everything before the_) ;
then
code here
fi
sometimes I'l have db be somethin_blah
and username will be 'something' (minus the last letter or letters) how would I do the same thing there

hope I was clear enough
help would be appreciated

Tombstone
aka
Tommy two cups

falko
1st June 2006, 01:27
Have a look here: http://www.tldp.org/LDP/abs/html/index.html and especially here: http://www.tldp.org/LDP/abs/html/tests.html