Re: sed with several lines, how?

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

 



thank you, and sorry, if i had formulated wrong, but the "SOMETEXT#X"
is a random STRING, like:

$ cat testfile.txt
alsjflsajfkljasdf
<br><font size=3>asfklasjlkyxcvo</font><br>
<br><font size=3>kldfjlkasjdfasdf</font><br>
kasfjxcvklajdflas

yxcvkjasafjads
<br><font size=3>asdfjkldjlasj</font><br>
</font></div></body></html>
uiyxzckjhasfsd
$



$ awk 'BEGIN {sawpattern=0} "^SOMETEXT, ^SOMETEXT" {if (($0
~/<br><font size=3>SOMETEXT/ ) && (sawpattern == 0)) {sawpattern=1}
else {sawpattern=0;print $0}}' testfile.txt
alsjflsajfkljasdf
<br><font size=3>asfklasjlkyxcvo</font><br>
<br><font size=3>kldfjlkasjdfasdf</font><br>
kasfjxcvklajdflas

yxcvkjasafjads
<br><font size=3>asdfjkldjlasj</font><br>
</font></div></body></html>
uiyxzckjhasfsd
$

On 27 November 2010 12:39, Arthur Bela <jozsi.avadkan@xxxxxxxxx> wrote:
> hyphen's [ - ] are just for marking the start/end of a pattern, but
> there are _not in_ the pattern!
> "OUTPUT" is what i want after "seding" the PATTERN#X's
>
>
> so i for e.g.: need the first, and second "magic"
> sed "FIRSTMAGIC" PATTERN#1
> sed "SECONDMAGIC" PATTERN#2
>
>
>
>
> PATTERN#1:
>
> -----------------------------------
> SOMETEXT#1
> <br><font size=3>SOMETEXT#2</font><br>
> <br><font size=3>SOMETEXT#3</font><br>
> SOMETEXT#4
> -----------------------------------
>
> "exact pattern", what is unique from the pattern:
> -----------------------------------
> </font><br>\n<br><font size=3>
> -----------------------------------
>
> OUTPUT:
> -----------------------------------
> SOMETEXT#1
> <br><font size=3>SOMETEXT#3</font><br>
> SOMETEXT#4
> -----------------------------------
>
>
>
>
>
> and:
>
> PATTERN#2:
>
> -----------------------------------
> SOMETEXT#1
> <br><font size=3>SOMETEXT#2</font><br>
> </font></div></body></html>
> SOMETEXT#3
> -----------------------------------
>
> "exact pattern", what is unique from the pattern:
> -----------------------------------
> </font><br>\n</font></div></body></html>
> -----------------------------------
>
> OUTPUT:
> -----------------------------------
> SOMETEXT#1
> </font></div></body></html>
> SOMETEXT#3
> -----------------------------------
>
>
> i just can't figure it out, how to "sed" when having several lines
> [nor in awk, perl..]
>
> could anyone post a link, or some guide, how to write these two lines of "sed"?
>
> Thank You! :\
>
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux