Reputation: 24383
I have a file containing much TeX mark-up, like this:
The fish ate 20\percent more food than the bear.
The fish ate \the\number\percent more food than the bear.
I want to delete that text which is a TeX code, like \percent
and replace it with a space.
\
.{
, or another \
.\
is never used in other situations in the file.How can I delete the appearance of these items, which begin with \
and afterwards are followed by a space, {
, or another \
?
Upvotes: 2
Views: 120
Reputation: 785146
You can use this perl command:
perl -pe 's#\\[^ \\{]+# #g' file.txt
OR using sed:
sed -E 's#\\[^ \\{]+# #g' file.txt
OR if -E is not supported then:
sed -r 's#\\[^ \\{]+# #g' file.txt
The fish ate 20 more food than the bear.
The fish ate more food than the bear.
Upvotes: 3