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!

Extract two fields (using command line, not an awk file)

Status
Not open for further replies.

630111

MIS
Oct 30, 2001
127
US
Here's part of my input file...

Client: p0691t01
Backup ID: p0691t01_1089702189
Policy: NON_PROD_SOLARIS
Policy Type: Standard (0)
Proxy Client: (none specified)
Creator: root
.
.
.

All I need is to get the Client and Policy fields like this ...

p0691t01 NON_PROD_SOLARIS (single space in between is ok)

...and I tried piping it to

awk '$1 ~ /(^Client:)|(^Policy:)/'

but I end up with this...

Client: bkrdevapp07
Policy: NON_PROD_WINDOWS
Client: bkrdevarc03
Policy: PROD_WINDOWS
Client: bkrdevexc03
Policy: NON_PROD_WINDOWS
Client: bkrdevsql01
Policy: NON_PROD_WINDOWS

Would appreciate any and all suggestions.

Thanks!
630111
 
Code:
/^Client:/ { printf $2 OFS }
/^Policy:/ { print $2 }

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Something like this ?
awk -F':' '
/^Client:/{clt=$2}
/^Policy:/{print clt,$2}
' /path/to/inputfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top