Question

I am working on a script to extract the processor set number followed by the processor ids that fall under that processor set in Solaris in bash shell:

Here is the output I want to extract from: (contents of $output)

user processor set 1: processors 0 1
user processor set 2: processors 2 8 9
user processor set 3: processors 3 4 5 6 7

Desired output is:

1: 0 1
2: 2 8 9
3: 3 4 5 6 7

The code i wrote using nawk:

print $output | nawk '                                 
BEGIN { ORS="\n" ; OFS = " " }
{
print$4; print OFS
for (i=6;i<=NF;i++)
print $i
}'

obtained output:

1: 
0 
1
2: 
2 
8 
9
3:  
3 
4 
5 
6 
7

Can anyone help and let me know what I am missing from obtaining the desired output . Thanks in advance.

EDIT: Idea to use OFS and ORS are obtained from this tutorial: tutorial link

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top