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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 ? |
| |||
| 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... . . |
| ||||
| 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 |