Rows into column with Header
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am working on a script where I need to print the output of below command and get it in an excel sheet:
Command is:
ifconfig -a |grep -i bond
Output is:
bond0 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X3:X4
bond1 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X4:X5
This command I need to run on multiple server using for loop.
However, I need to bring in excel sheet in below format:
Server Name Bond Name Link Encap Hwaddr
xxxxxx bond0 Ethernet B1:B2:X1:X2:X3:X4
xxxxxx bond1 Ethernet B1:B2:X1:X2:X4:X5
linux shell-script
add a comment |
up vote
0
down vote
favorite
I am working on a script where I need to print the output of below command and get it in an excel sheet:
Command is:
ifconfig -a |grep -i bond
Output is:
bond0 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X3:X4
bond1 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X4:X5
This command I need to run on multiple server using for loop.
However, I need to bring in excel sheet in below format:
Server Name Bond Name Link Encap Hwaddr
xxxxxx bond0 Ethernet B1:B2:X1:X2:X3:X4
xxxxxx bond1 Ethernet B1:B2:X1:X2:X4:X5
linux shell-script
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on a script where I need to print the output of below command and get it in an excel sheet:
Command is:
ifconfig -a |grep -i bond
Output is:
bond0 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X3:X4
bond1 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X4:X5
This command I need to run on multiple server using for loop.
However, I need to bring in excel sheet in below format:
Server Name Bond Name Link Encap Hwaddr
xxxxxx bond0 Ethernet B1:B2:X1:X2:X3:X4
xxxxxx bond1 Ethernet B1:B2:X1:X2:X4:X5
linux shell-script
I am working on a script where I need to print the output of below command and get it in an excel sheet:
Command is:
ifconfig -a |grep -i bond
Output is:
bond0 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X3:X4
bond1 Link encap: Ethernet Hwwaddr: B1:B2:X1:X2:X4:X5
This command I need to run on multiple server using for loop.
However, I need to bring in excel sheet in below format:
Server Name Bond Name Link Encap Hwaddr
xxxxxx bond0 Ethernet B1:B2:X1:X2:X3:X4
xxxxxx bond1 Ethernet B1:B2:X1:X2:X4:X5
linux shell-script
linux shell-script
edited Nov 18 at 9:31
Rui F Ribeiro
38.2k1475123
38.2k1475123
asked Aug 19 '16 at 19:02
Vikas Thakur
105
105
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16
add a comment |
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
This should work with bash shell. It will give you CSV output which is easily imported into Excel.
#!/bin/bash
printf 'Server Name,Bond Name,Link Encap,Hwaddrn'
for line in "$(ifconfig -a|grep -i bond)"
do
echo -n $(hostname),
set $line
echo $1,$3//encap:/,$5
done
This will produce your desired output running on a single server. Since you don't mention how you plan to run it on multiple servers to generate the data, you may need to alter this slightly to suit your needs.
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
This should work with bash shell. It will give you CSV output which is easily imported into Excel.
#!/bin/bash
printf 'Server Name,Bond Name,Link Encap,Hwaddrn'
for line in "$(ifconfig -a|grep -i bond)"
do
echo -n $(hostname),
set $line
echo $1,$3//encap:/,$5
done
This will produce your desired output running on a single server. Since you don't mention how you plan to run it on multiple servers to generate the data, you may need to alter this slightly to suit your needs.
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
|
show 3 more comments
up vote
0
down vote
accepted
This should work with bash shell. It will give you CSV output which is easily imported into Excel.
#!/bin/bash
printf 'Server Name,Bond Name,Link Encap,Hwaddrn'
for line in "$(ifconfig -a|grep -i bond)"
do
echo -n $(hostname),
set $line
echo $1,$3//encap:/,$5
done
This will produce your desired output running on a single server. Since you don't mention how you plan to run it on multiple servers to generate the data, you may need to alter this slightly to suit your needs.
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
|
show 3 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
This should work with bash shell. It will give you CSV output which is easily imported into Excel.
#!/bin/bash
printf 'Server Name,Bond Name,Link Encap,Hwaddrn'
for line in "$(ifconfig -a|grep -i bond)"
do
echo -n $(hostname),
set $line
echo $1,$3//encap:/,$5
done
This will produce your desired output running on a single server. Since you don't mention how you plan to run it on multiple servers to generate the data, you may need to alter this slightly to suit your needs.
This should work with bash shell. It will give you CSV output which is easily imported into Excel.
#!/bin/bash
printf 'Server Name,Bond Name,Link Encap,Hwaddrn'
for line in "$(ifconfig -a|grep -i bond)"
do
echo -n $(hostname),
set $line
echo $1,$3//encap:/,$5
done
This will produce your desired output running on a single server. Since you don't mention how you plan to run it on multiple servers to generate the data, you may need to alter this slightly to suit your needs.
edited Aug 19 '16 at 20:54
answered Aug 19 '16 at 20:38
MikeA
70226
70226
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
|
show 3 more comments
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
No sane mammalian that uses unix/linux and bash would ever use excel.
– ott--
Aug 19 '16 at 21:23
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
Well of course not! ;-) Just giving the OP the data asked for in a format he could use in the application he wanted.
– MikeA
Aug 19 '16 at 22:13
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I missed that indeed.
– ott--
Aug 19 '16 at 23:00
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
I am running it on multiple server inside for loop.
– Vikas Thakur
Aug 21 '16 at 14:01
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
If you will be running it manually on each server, the above should work. If you are going to fire off something from one host to SSH to other servers to get this information, just wrap another loop around the code here to connect to your remote hosts.
– MikeA
Aug 22 '16 at 15:31
|
show 3 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f304536%2frows-into-column-with-header%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
ifconfig -a | grep -ie bond -e "server nane"
– ott--
Aug 19 '16 at 21:16