Skip to content
Advertisement

How to change *** to textbf with sed

I export results from my analysis into a table in Latex. I would like to be able to change all coefficients that are significant to ***, **, * to bold face text textbf. This requires me to search with sed and change the stars to wrap around the coefficient.

I want to change 0.047$^{***}$ to textbf{0.047}

I’ve been trying, sed /s/$^{***}$/}, but this is only remove $^{***}$.

How do I insert textbf{ at the beginning of the number and a closing bracket } at the end?

Advertisement

Answer

I think you should learn about regexes and see manpage for sed.

Then, according to this answer, and this regex, you can do:

sed -r 's/([0-9.]+)$^{*{1,3}}$/\textbf{1}/g' filename
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement