Rows into column with Header

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question























  • ifconfig -a | grep -ie bond -e "server nane"
    – ott--
    Aug 19 '16 at 21:16















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









share|improve this question























  • ifconfig -a | grep -ie bond -e "server nane"
    – ott--
    Aug 19 '16 at 21:16













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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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











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.






share|improve this answer






















  • 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










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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

























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.






share|improve this answer






















  • 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














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.






share|improve this answer






















  • 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












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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay