Hi I have a fairly large but messy output from a salt script I'm running.
Basically my cleanest output looks like this:
MINION:server1.xyz.com
MINION:server2.xyz.com
MINION:server3.xyz.com
filer1:/vol/storagestuffs/volpath1
filer1:/vol/storagestuffs/volpath2
filer1:/vol/storagestuffs/volpath3
filer1:/vol/storagestuffs/volpath4
MINION:server4.xyz.com
filer4:/vol/storagestuffs/volpath1
MINION:server5.xyz.com
MINION:server6.xyz.com
MINION:server7.xyz.com
filer3:/vol/storagestuffs/volpath1
What I want is ONLY to return the minions that have filers beneath them and all of the filers beneath them and I'd like to get it formatted as such:
MINION:server3.xyz.com filer1:/vol/storagestuffs/volpath1
MINION:server3.xyz.com filer1:/vol/storagestuffs/volpath2
MINION:server3.xyz.com filer1:/vol/storagestuffs/volpath3
MINION:server3.xyz.com filer1:/vol/storagestuffs/volpath4
MINION:server4.xyz.com filer4:/vol/storagestuffs/volpath1
MINION:server7.xyz.com filer3:/vol/storagestuffs/volpath1
I've looked into if statements, recursive statements, etc. I either am failing to understand bash recursive statements or thats not what I want to do. I'm hoping to find an efficient way of doing this without scanning the file more than once.
Is there a tricky way to use xargs? Is there something in grep that can do this?
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire