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

sed / awk / perl / other to get header info 1

Status
Not open for further replies.

mrn

MIS
Apr 27, 2001
3,993
0
0
GB
Hi All,

I've got some data from an AIX HMC in the following format (All on one line).

Code:
name=standard,lpar_name=lpar123,lpar_id=123,lpar_env=aixlinux,all_resources=0,min_mem=2048,desired_mem=4096,max_mem=12228,min_num_huge_pages=0,desired_num_huge_pages=0,max_num_huge_pages=0,mem_mode=ded,proc_mode=shared,min_proc_units=0.1,desired_proc_units=0.1,max_proc_units=0.5,min_procs=1,desired_procs=1,max_procs=2,sharing_mode=uncap,uncap_weight=128,shared_proc_pool_id=1,shared_proc_pool_name=CPUPool,io_slots=none,lpar_io_pool_ids=none,max_virtual_slots=40,"virtual_serial_adapters=0/server/1/any//any/1,1/server/1/any//any/1","virtual_scsi_adapters=2/client/2/vio002/53/0,3/client/3/vio003/53/0","virtual_eth_adapters=16/0/100//0/0/ETHERNET0,17/0/200//0/0/ETHERNET0,18/0/300//0/0/ETHERNET0,15/0/400//0/0/ETHERNET0",hca_adapters=none,boot_mode=norm,conn_monitoring=1,auto_start=0,power_ctrl_lpar_ids=none,work_group_id=none,redundant_err_path_reporting=0,bsr_arrays=0,lpar_proc_compat_mode=POWER6_enhanced,electronic_err_reporting=null,virtual_fc_adapters=none

I want to get the header info, E.g everything before the = sign for each field, I initially thought this would be easy, but have hit a few issues.

Code:
sed -e s?=[a-z0-90-9.0-9A-Z0-9/]*,?#?g

produces

Code:
name#lpar_name#lpar_id#lpar_env#all_resources#min_mem#desired_mem#max_mem#min_num_huge_pages#desired_num_huge_pages#max_num_huge_pages#mem_mode#proc_mode#min_proc_units#desired_proc_units#max_proc_units#min_procs#desired_procs#max_procs#sharing_mode#uncap_weight#shared_proc_pool_id#shared_proc_pool_name#io_slots#lpar_io_pool_ids#max_virtual_slots#"virtual_serial_adapters#1/server/1/any//any/1","virtual_scsi_adapters#3/client/3/vio003/53/0","virtual_eth_adapters#17/0/200//0/0/ETHERNET0,18/0/300//0/0/ETHERNET0,15/0/400//0/0/ETHERNET0",hca_adapters#boot_mode#conn_monitoring#auto_start#power_ctrl_lpar_ids#work_group_id#redundant_err_path_reporting#bsr_arrays#lpar_proc_compat_mode=POWER6_enhanced,electronic_err_reporting#virtual_fc_adapters=none

But it all goes wrong on the second set of slashes. I have a solution but it's a very nasty series of sed statments.

I'm sure I'm missing a very easy way of doing this.

Also may have to handle different header lengths and different number of headers, but all are in the format

header="not ,needed", or header=not needed,

Any ideas.


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
What about this ?
Code:
sed 's!"\([^=]*\)=[^"]*"!\1!g;s!=[^,]*!!g;s!,!#!g' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That worked a treat. Thank You very much.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Not an answer to your question, but have you tried the options [tt]--header -F[/tt] on your HMC commands?


HTH,

p5wizard
 
Hi p5,

Tried that but we have 50+ hmc's all at different levels some really early. Thought it easier just to grab everything and strip off the headers from each one.


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top