How to pass a variable from bash to regex -



How to pass a variable from bash to regex -

i'm trying print lines contain variable $foo. i've tried using double quotes , curly braces no avail. proper way pass shell variable regex in sed?

sed -n 's:\("${foo}".*$\):\1:p' file.txt

sed overkill if don't need modify matching lines. utilize grep:

grep "$foo" file.txt

regex bash sed sh

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -