For Programmers: Free Programming Magazines  


Home > Archive > AWK > July 2004 > help with sed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help with sed
Michael

2004-07-26, 3:55 am

I need to replace a line that starts with a tab with "\f what was
originally in the line \f". Can anyone help please?
Kenny McCormack

2004-07-26, 3:55 am

In article <d178a992.0407251746.11ef292f@posting.google.com>,
Michael <mssmith79@yahoo.com> wrote:
>I need to replace a line that starts with a tab with "\f what was
>originally in the line \f". Can anyone help please?


<On-Topic>
1+sub(/^\t.*/,"\f&\f")
</On-Topic>
Bob Harris

2004-07-26, 3:55 am

In article <d178a992.0407251746.11ef292f@posting.google.com>,
mssmith79@yahoo.com (Michael) wrote:

> I need to replace a line that starts with a tab with "\f what was
> originally in the line \f". Can anyone help please?


sed 's/\( .*\)/\\f\1\\f/' <<EOD
Hi
This line starts with a tab
yo
This is another line that starts with a tab
this is a space line
hello
EOD

Example of output:
Hi
\f This line starts with a tab\f
yo
\f This is another line that starts with a tab\f
this is a space line
hello

If you mean \f is formfeed, then you will have to use something beside
\\f in the substitution.

If you do not want to include the tab in the output, then move the \( to
after the tab character.

Bob Harris
Michael

2004-07-26, 3:55 pm

Thanks guys. I used Bob's but I had to use s/\(^i.*\) then the rest
was the same. Thanks again from the newb.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com