I have a command that gives the following output:
#sec one
a : same
b : red
c : one
d :
e :
f :
#sec two
a : same
b : blue
c : two
d :
e :
#sec three
a : different
b : green
c : three
d :
e :
#sec four
a : different
b : yellow
c : four
#sec five
a : different
b : pink
c : five
There are a lot of such sections. I need only the sections that have a : same
and the value of b
and c
fields for those sections.
Sample output:
#sec one
a : same
b : red
c : one
#sec two
a : same
b : blue
c : two
This is what I've done so far! Tr -s to make it equally spaced.
mycommand | tr -s " " | cut -d ':' -f 2
Does anyone know another way of doing it or using conditionals in cut statements?