Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select few fields until condition

Status
Not open for further replies.

Currando

ISP
Feb 13, 2001
25
ES
Hello,

I need a program that search in a input file a string, when this string is maching i want to copy all lines until a white line, and loop until end off file, example:

"INPUT FILE "

dn:radiuslist=reply,radiusname=thia2000@arrakis.net,radiusclass=Native-User,o=
radius
changetype: add
objectclass: top
objectclass: reply
radiuslist: reply
framed-ip-address: [pool] GSMBOX.ES
framed-ip-netmask: 255.255.255.255
primary-dns-server: 212.59.199.2
secondary-dns-server: 212.59.199.6

dn: radiusname=francesco.zanieri@jumpy,radiusclass=Native-User,o=radius
changetype: add
objectclass: top
objectclass: Native-User
objectclass: user
radiusname: zanieri@jumpy
password: {x-clear}tegamino
login-limit: 1

dn: radiuslist=check,radiusname=francesco.zanieri@jumpy,radiusclass=Native-User,o=radius
changetype: add
objectclass: top
objectclass: check

I want that the program search the string "jumpy" and copy all record to output file until a white line in all file.

I make this program but whent found the first string the condition is broken:
{
if (/jumpy/) {
do {
print
getline
} while ($1 != /- / || $1 != RS)
if (/EOF/) {print}
} else next

}
Can anyboy help me :)
 
This awk script works properly only if you search pattern in first row of record (dn: ...):

/jumpy/ { printOn = 1 }

{ if (printOn) print $0 }

/^$/ { printOn = 0 }

Awk is simple.

Jesus loves you!

KP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top