I have a bash script that I am trying to learn from. I have a sql file that has in it:
create user myuser with password 'mypassword';
I want to use sed and store the value of the password in one bash variable and the pasword in another bash variable. The script that I am learning from has:
USERNAME := $(shell sed -n \
"s/^create user \(\S\+\) with password '\(\S\+\)';$$/\1/p" \
createdb.sql)
PASSWORD := $(shell sed -n \
"s/^create user \(\S\+\) with password '\(\S\+\)';$$/\2/p" \
createdb.sql)
No matter what I tried the regex would not match up. Part of my issue is I don't understand the basics of sed. How do I go about getting the value of parts of the string?