Unix Technical Forum

awk in a stanza file

This is a discussion on awk in a stanza file within the AIX Operating System forums, part of the Unix Operating Systems category; --> hi I am trying to find a way of pulling certain fields out an AIX stanza file. In the ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 06:59 AM
Weed
 
Posts: n/a
Default awk in a stanza file

hi

I am trying to find a way of pulling certain fields out an AIX stanza
file. In the file /etc/qconfig I need the following fields extracted
so i can then use them in a Excel spreadsheet.

The fields are:

xxxxx: (UNIX queue name)
device = @xxxxxx

host = xxxxxx (Windows host name)

rq = xxxx (Actual Windows queue name)

Any ideas ?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 06:59 AM
rcee
 
Posts: n/a
Default Re: awk in a stanza file

Try using sed with a paragraph option

Like ,
sed -n "/username/,/password/p" passwd
will take out the username his encrypted password from the
/etc/security/paswd file

rgrds
RC

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 06:59 AM
sllabres
 
Posts: n/a
Default Re: awk in a stanza file

Hmmm don't known if there is allway host, rq,.. defined but something
like:

grep "^[^\*]" qconfig | \
awk -v FS="=" '
/:[ \t]*$/ { D=$0; DEV[$0]=" "; }
/device.*=/ { DEV[D]=DEV[D]$2 }
/host.*=/ { DEV[D]=DEV[D]$2 }
/rq.*=/ { DEV[D]=DEV[D]$2 }
END {
for (DEVS in DEV) { printf("%s %s\n",DEVS,DEV[DEVS])}
}'

probably.

Bye, Stefan... . .

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 07:00 AM
mark
 
Posts: n/a
Default Re: awk in a stanza file

you can do it with awk, just change your field seperators using '{BEGIN
FS="\n" ,RS=""} i.e. , seperate fields by lines and records by blank.

alternatively if you want the data in a colon seperated format(which is
-IMHO - easier ) then use the lsque and lsquedev commands with the -c
flag

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:40 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com