文本:
\item Further course of adolescent \uline{maturation and synaptic questions} to identify genes and circuit development factors associated with departures from normal developmental functioning, and \uline{points in prodromal stages where intervention} might particularly be targeted;
目标:在段落
中将\uline{ text... }
替换为{\color{cname}\uline{ text... }}
代码:
#!/usr/local/bin/zsh
sed -i -n "96,300 {
s/\(\\\\uline{.*}\)/{\\\\color{cname}\1}/g
}" tmpName.tex
# issue: can't parse the second \uline !!
然而,得到这样的输出:
\item Further course of adolescent {\color{cname}\uline{maturation and synaptic questions} to identify genes and circuit development factors associated with departures from normal developmental functioning, and \uline{points in prodromal stages where intervention}} might particularly be targeted;
任何帮助将不胜感激!
答案 0 :(得分:1)
sed 's#\\uline{[^}]*}#{\\color{cname}&}#g' file
根据需要添加行范围或-i
。
用你的文字测试:
kent$ cat f
\item Further course of adolescent \uline{maturation and synaptic questions}
\uline{points in prodromal stages where intervention} foo
kent$ sed 's#\\uline{[^}]*}#{\\color{cname}&}#g' f
\item Further course of adolescent {\color{cname}\uline{maturation and synaptic questions}}
{\color{cname}\uline{points in prodromal stages where intervention}} foo