0

I have wrote the simple script

#!/bin/bash

progname=$1

sed -i.bak 's/#define SFFX ".*"/#define SFFX "$progname"/' path/to/file

In order to find a preprocessor directive in a C file and change it with bash. Problem is that the varibale identyfier $progname is not expanded, so that the substitution of the string #define SFFX "_foo" does not result in #define SFFX "_bar" when i run ./myscript.sh "bar".

How can one expand the varible i pass from command line into the regexp?

0 Answers0