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

ruby on rails - Devise Logout Error in RoR -

model view controller - MVC Rails Planning -

php - Working with pretty urls on apache and fastcgi after hhvm installation -