FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 11-27-2010, 11:36 AM
Christopher Chan
 
Default sed with several lines, how?

On Saturday, November 27, 2010 07:39 PM, Arthur Bela 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>
<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>
</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..]
>

Impossible with sed. You can use awk.

Output of: 'cat testpart'

SOMETEXT#1
<br><font size=3>SOMETEXT#2</font><br>
<br><font size=3>SOMETEXT#3</font><br>
SOMETEXT#4

SOMETEXT#1
<br><font size=3>SOMETEXT#2</font><br>
</font></div></body></html>
SOMETEXT#3

Output of: awk 'BEGIN {sawpattern=0} "^SOMETEXT, ^SOMETEXT" {if (($0 ~
/<br><font size=3>SOMETEXT/ ) && (sawpattern == 0)) {sawpattern=1} else
{sawpattern=0;print $0}}' testpart

SOMETEXT#1
<br><font size=3>SOMETEXT#3</font><br>
SOMETEXT#4

SOMETEXT#1
</font></div></body></html>
SOMETEXT#3

That seems to be what you are looking for.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-27-2010, 12:03 PM
Arthur Bela
 
Default sed with several lines, how?

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 13:36, Christopher Chan
<christopher.chan@bradbury.edu.hk> wrote:
> On Saturday, November 27, 2010 07:39 PM, Arthur Bela 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>
<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>
</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..]
>>
>
> Impossible with sed. You can use awk.
>
> Output of: 'cat testpart'
>
> SOMETEXT#1
> <br><font size=3>SOMETEXT#2</font><br>
> <br><font size=3>SOMETEXT#3</font><br>
> SOMETEXT#4
>
> SOMETEXT#1
> <br><font size=3>SOMETEXT#2</font><br>
> </font></div></body></html>
> SOMETEXT#3
>
> Output of: awk 'BEGIN {sawpattern=0} "^SOMETEXT, ^SOMETEXT" {if (($0 ~
> /<br><font size=3>SOMETEXT/ ) && (sawpattern == 0)) {sawpattern=1} else
> {sawpattern=0;print $0}}' testpart
>
> SOMETEXT#1
> <br><font size=3>SOMETEXT#3</font><br>
> SOMETEXT#4
>
> SOMETEXT#1
> </font></div></body></html>
> SOMETEXT#3
>
> That seems to be what you are looking for.
>
> --
> ubuntu-users mailing list
> ubuntu-users@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-27-2010, 12:03 PM
Arthur Bela
 
Default sed with several lines, how?

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@gmail.com> 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>
<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>
</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! :
>


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTim+cy7x9WqnTxpee4KrSB6nQt=WAMckttgn814y@mail .gmail.com">http://lists.debian.org/AANLkTim+cy7x9WqnTxpee4KrSB6nQt=WAMckttgn814y@mail .gmail.com
 
Old 11-27-2010, 12:03 PM
Arthur Bela
 
Default sed with several lines, how?

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@gmail.com> 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>
<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>
</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@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 11-27-2010, 12:03 PM
Arthur Bela
 
Default sed with several lines, how?

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@gmail.com> 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>
<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>
</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! :
>
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-27-2010, 12:27 PM
Christopher Chan
 
Default sed with several lines, how?

awk 'BEGIN {sawpattern=0} "^[[:alpha:]], ^[[:alpha:]]" {if (($0
~/<br><font size=3>[[:alpha:]]/ )&& (sawpattern == 0)) {sawpattern=1}
else {sawpattern=0;print $0}}' testfile.txt

I don't know how your files are exactly formatted. Please look up the
documentation if you need to further finetune.

man awk
man 7 regex

On Saturday, November 27, 2010 09:03 PM, Arthur Bela wrote:
> 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 13:36, Christopher Chan
> <christopher.chan@bradbury.edu.hk> wrote:
>> On Saturday, November 27, 2010 07:39 PM, Arthur Bela 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>
<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>
</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..]
>>>
>>
>> Impossible with sed. You can use awk.
>>
>> Output of: 'cat testpart'
>>
>> SOMETEXT#1
>> <br><font size=3>SOMETEXT#2</font><br>
>> <br><font size=3>SOMETEXT#3</font><br>
>> SOMETEXT#4
>>
>> SOMETEXT#1
>> <br><font size=3>SOMETEXT#2</font><br>
>> </font></div></body></html>
>> SOMETEXT#3
>>
>> Output of: awk 'BEGIN {sawpattern=0} "^SOMETEXT, ^SOMETEXT" {if (($0 ~
>> /<br><font size=3>SOMETEXT/ )&& (sawpattern == 0)) {sawpattern=1} else
>> {sawpattern=0;print $0}}' testpart
>>
>> SOMETEXT#1
>> <br><font size=3>SOMETEXT#3</font><br>
>> SOMETEXT#4
>>
>> SOMETEXT#1
>> </font></div></body></html>
>> SOMETEXT#3
>>
>> That seems to be what you are looking for.
>>
>> --
>> ubuntu-users mailing list
>> ubuntu-users@lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>>
>


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-27-2010, 01:02 PM
Christopher Chan
 
Default sed with several lines, how?

Hahahaha,

I see that you posted this in quite a few places. Let me repeat it here
then. BTW, do a bit of homework if you do need fine tuning before
posting back on this list.

awk 'BEGIN {sawpattern=0} "^[[:alpha:]], ^[[:alpha:]]" {if (($0
~/<br><font size=3>[[:alpha:]]/ )&& (sawpattern == 0)) {sawpattern=1}
else {sawpattern=0;print $0}}' testfile.txt

I don't know how your files are exactly formatted. Please look up the
documentation if you need to further finetune.

man awk
man 7 regex


On Saturday, November 27, 2010 09:03 PM, Arthur Bela wrote:
> 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@gmail.com> 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>
<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>
</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! :
>>
> _______________________________________________
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-27-2010, 03:05 PM
Johannes Wiedersich
 
Default sed with several lines, how?

Arthur Bela wrote:
> i just can't figure it out, how to "sed" when having several lines
> [nor in awk, perl..]

I have not really understood your question, but maybe this will help you:

http://www.grymoire.com/Unix/Sed.html#uh-51

I would go someway along the lines of removing the newline at the end,
then replacing the full expression.

Johannes


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4CF12C37.3000604@aktendiener.de">http://lists.debian.org/4CF12C37.3000604@aktendiener.de
 
Old 11-27-2010, 04:58 PM
Mark
 
Default sed with several lines, how?

On Sat, Nov 27, 2010 at 5:27 AM, Christopher Chan
<christopher.chan@bradbury.edu.hk> wrote:
> awk 'BEGIN {sawpattern=0} "^[[:alpha:]], ^[[:alpha:]]" {if (($0
> *~/<br><font size=3>[[:alpha:]]/ )&& *(sawpattern == 0)) {sawpattern=1}
> else {sawpattern=0;print $0}}' testfile.txt
>
> I don't know how your files are exactly formatted. Please look up the
> documentation if you need to further finetune.
>
> man awk
> man 7 regex
>
> On Saturday, November 27, 2010 09:03 PM, Arthur Bela wrote:
>> 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 13:36, Christopher Chan
>> <christopher.chan@bradbury.edu.hk> *wrote:
>>> On Saturday, November 27, 2010 07:39 PM, Arthur Bela 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>
<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>
</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..]
>>>>
>>>
>>> Impossible with sed. You can use awk.
>>>
>>> Output of: 'cat testpart'
>>>
>>> SOMETEXT#1
>>> <br><font size=3>SOMETEXT#2</font><br>
>>> <br><font size=3>SOMETEXT#3</font><br>
>>> SOMETEXT#4
>>>
>>> SOMETEXT#1
>>> <br><font size=3>SOMETEXT#2</font><br>
>>> </font></div></body></html>
>>> SOMETEXT#3
>>>
>>> Output of: awk 'BEGIN {sawpattern=0} "^SOMETEXT, ^SOMETEXT" {if (($0 ~
>>> /<br><font size=3>SOMETEXT/ )&& *(sawpattern == 0)) {sawpattern=1} else
>>> {sawpattern=0;print $0}}' testpart
>>>
>>> SOMETEXT#1
>>> <br><font size=3>SOMETEXT#3</font><br>
>>> SOMETEXT#4
>>>
>>> SOMETEXT#1
>>> </font></div></body></html>
>>> SOMETEXT#3
>>>
>>> That seems to be what you are looking for.
>>>
>>> --
>>> ubuntu-users mailing list
>>> ubuntu-users@lists.ubuntu.com
>>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>>>
>>
>
>
> --
> ubuntu-users mailing list
> ubuntu-users@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>

Could you both please stop top-posting?

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-27-2010, 11:33 PM
Christopher Chan
 
Default sed with several lines, how?

On Sunday, November 28, 2010 01:58 AM, Mark wrote:

>
> Could you both please stop top-posting?
>

I do believe this thread is dead until something very specific from the
OP turns up.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 05:31 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org