bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed problem


From: lina
Subject: Re: sed problem
Date: Mon, 2 Apr 2012 22:35:03 +0800

On Sat, Aug 13, 2011 at 11:14 PM, Francky Leyn <address@hidden> wrote:
> Hello,
>
> I have the following problem: I must write a sed script that
> converts parts of groff syntax to LaTeX syntax.
>
> eg: .BI -o gif_output_file -> \textbf{-o} \textit{gif\_output\_file}
>
> Lets neglect the underscores for the moment.
>
> This can be dan with
>
> s/\.BI \([^ ]*\) \([^ ]*\)/\\textbf{\1} \\textit{\2}/
>
> However, it also has to work for:
>
> eg: .BI -o " gif_output_file
>
> It doesn't: this is the output:
>
> \textbf{-o} \textit{"} gif\_output\_file"
>
> Of couse.
>
> My question: how do you write it correctly in sed?


I came up with a very clumsy one, but easily to see what's going on,
anyway, it seems work.

$ echo "BI -o\" gif_output_file" | sed  -e 's/.* \(\-o\)\([\"]*\)
\(.*\)/\\texbf{\1} \\textit{\2} \\textit{\3}/g; s/\_/\\_/g ; s/
\\textit{}//g '
\texbf{-o} \textit{"} \textit{gif\_output\_file}

echo "BI -o gif_output_file" | sed  -e 's/.* \(\-o\)\([\"]*\)
\(.*\)/\\texbf{\1} \\textit{\2} \\textit{\3}/g; s/\_/\\_/g ; s/
\\textit{}//g '
\texbf{-o} \textit{gif\_output\_file}


You are welcome.


>
> Best reagrds,
>
> Francky



reply via email to

[Prev in Thread] Current Thread [Next in Thread]