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 -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -