Reputation: 27
I have a line of latex source code which I want to replace. The problem is, it contains curved brackets and backslash. Furthermore, I would like to replace it with a bash variable
Before: In case0.tex
, I have this line:
\title{Analysis Case 0}
I want to change the title inside the curved bracket to a string contained in a bash variable called $CASE
.
This is what I tried, however I am not sure how to treat this special case with sed
.
CASE=Analysis Case 1
sed -e "s/ \title{Analysis Case 0} / \title{ $CASE } /g" ./case0.tex > ./case1.tex
After: In case1.tex
I would like to get this line.
\title{Analysis Case 1}
It would be nice if someone could tell me how to do that!
Upvotes: 0
Views: 166
Reputation: 11237
Using sed
$ case="Analysis Case 1"
$ sed s"/\({\)[^}]*/\1$case/" case0.tex > case1.tex
$ cat case1.tex
\title{Analysis Case 1}
Upvotes: 1