1752591 Members
2713 Online
108788 Solutions
New Discussion юеВ

combinig o/p

 
SOLVED
Go to solution
Soul_1
Respected Contributor

combinig o/p

Hi all,

i wrote one script to get the node details.

#!/usr/bin/sh
#Script to check the node details
Node=$(/opt/OV/bin/ovtopodump -lr|grep "NODE LABEL"|awk '{print $3}')
Int=$(/opt/OV/bin/ovtopodump -lr|grep "NUMBER OF INTERFACES")
Detail="$Node $Int"
echo "$Detail \c\n"
_______________________________
The o/p of this command is will be
Node=$(/opt/OV/bin/ovtopodump -lr|grep "NODE LABEL"|awk '{print $3}')

xyz.co.in
yyy.co.in
sss.co.in
ttt.co.in

and o/p of second command Int=$(/opt/OV/bin/ovtopodump -lr|grep "NUMBER OF INTERFACES")
is
interfaces 30
interfaces 120
interfaces 12
interfaces 44

what is my req is i want to display the o/p in one line

i.e
xyz.co.in interfaces 30
yyy.co.in interfaces 120
sss.co.in interfaces 12

but i am getting o/p as
xyz.co.in
yyy.co.in
sss.co.in
ttt.co.in interfaces 30
interfaces 120
interfaces 12
interfaces 44


please guide me to achieve this .


Thanks to all in advance



12 REPLIES 12
Kapil Jha
Honored Contributor

Re: combinig o/p

there is ery simple utility called paste

paste file1 file2

outpur will be the one you want.

BR,
Kapil+

I am in this small bowl, I wane see the real world......
Soul_1
Respected Contributor

Re: combinig o/p

Hi ,

Thanks for the information.
It would be helpful if we combine the o/p without redirecting the result to another one and combibining it.


any way that was working.Thanks Once again
Kapil Jha
Honored Contributor

Re: combinig o/p

not sure but u can do like

Detail= paste $Node $Int
echo "$Detail \c\n"


this should work.


BR,
Kapil+
I am in this small bowl, I wane see the real world......
Soul_1
Respected Contributor

Re: combinig o/p

Hi,

It is not working, as it is not able to find the files.


Thanks & Regards,
Dennis Handly
Acclaimed Contributor

Re: combinig o/p

>It would be helpful if we combine the output without redirecting the result to another one and combining it.

You can probably do that if you use awk on the output of:
/opt/OV/bin/ovtopodump -lr | grep -e "NODE LABEL" -e "NUMBER OF INTERFACES"

Can you provide a sample of that that looks like?
TARUN SHARMA_1
Advisor

Re: combinig o/p

Just give a small o/p of (/opt/OV/bin/ovtopodump -lr to understand it better.
Sr Tech Lead
Tech Mahindra
Data Canter Tubli Bahrain
Viktor Balogh
Honored Contributor

Re: combinig o/p

try something like this:

# /opt/OV/bin/ovtopodump -lr |
awk '/NODE LABEL/ {printf $3"\t"}
/NUMBER OF INTERFACES/ {print $0}'

maybe it's not perfect because it is untested. But there's no need to run ovtopodump twice and grep can also be done with awk. Tailor it to your own needs.
****
Unix operates with beer.
Dennis Handly
Acclaimed Contributor

Re: combinig o/p

>Viktor: try something like this:

Assuming they come out in that order, you could also use a variable so you only have one print:
... | awk '
/NODE LABEL/ { NODE = $3 }
/NUMBER OF INTERFACES/ { print NODE, $0 }'
Soul_1
Respected Contributor

Re: combinig o/p

hi

Thanks all,

can you please tell me how this command works

1. /opt/OV/bin/ovtopodump -lr|awk '/NODE LABEL/ { NODE = $3 } /NUMBER OF INTERFACES/ { print NODE, $0 }'

2.
/opt/OV/bin/ovtopodump -lr | awk '/NODE LABEL/ {printf $3"\t"}/NUMBER OF INTERFACES/ {print $0}'

It would be great helpful if you explain how this works.

Thanks a lot

both are giving the desired o/p.