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
Post a Comment