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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting certain blocks of information from a file

Status
Not open for further replies.

octar

Technical User
Oct 21, 2002
28
AU
Hi, I would like to grab specific information out of the /etc/qconfig file... what I want is everything in the block starting with printxxx and then pxxx
eg.

>cat /etc/qconfig

print146:
device = hp@p146
hp@p146:
file = /var/spool/lpd/pio/@local/dev/hp@p146.server#hpJetDirect#9100
header = never
trailer = never
access = both
backend = /usr/lib/lpd/pio/etc/piojetd p146.server 9100

I have over 100 printers so would like to find the easy option instead of manually cutting and pasting my way through the qconfig file.

thanks
 
Not sure what your end condition is, but you can probably tailor the following to suit your needs:
Code:
#!/usr/bin/perl
open(FILE, "/etc/qconfig");
while(<FILE>) {
  print if /^print\d+:/ .. /p\d+$/;
}
close FILE;
Hope this helps. Cheers, Neil :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top