awk question

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

awk question

#1 Post by fabrice_035 »

Hello,

Can you help me please ?

First with wget i download a web page,
After with awk i search a first pattern and in need extract next other pattern, example:

web page contain :

blablabla,hello world!!!,my cat is funny, password 1234, blablabla

I want extract the fisrt pattern contain "password" after found "hello world!!!" pattern

Thanks all.

Regard.
[/quote]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#2 Post by step »

One way

Code: Select all

# echo 'blablabla,hello world!!!,my cat is funny, password 1234, blablabla' |awk '/hello world!!!/{if(match($0,/password [^,]+/)) print substr($0,RSTART,RLENGTH)}'
password 1234
Another way

Code: Select all

# echo 'blablabla,hello world!!!,my cat is funny, password 1234, blablabla' |gawk '/hello world!!!/{if(match($0,/password ([^,]+)/,a)) print a[1]}'
1234
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#3 Post by fabrice_035 »

@step, thanks guy :P

Post Reply