In my bash script, I'm going to have two variables called "args1" and "args2". Each one of them is going to have content like this:
Matching cluster names:
[a-z]+
[a-z]+
...
So "args1" could be:
Matching cluster names:
dev1ff
dev2ff
and "args2" could be:
Matching cluster names:
dev2ff
dev3ff
I need to combine these to produce:
Matching cluster names:
dev1ff
dev2ff
dev3ff
I can get close to this with this line:
echo "$(echo "$args1" | grep -v "^Matching") $(echo "$args2" | grep -v "^Matching")" | sort -u
This produces something roughly like this:
Matching clusters:
dev1ff
dev2ff dev3ff
The actual names are immaterial, but the issue is that I'm unable to jam a newline between the first and second block. I tried several variations of things in that space between the two "$(...)" blocks, but nothing worked.
echo -e "$(echo "$args1" | grep -v "^Matching") \n $(echo "$args2" | grep -v "^Matching")" | sort -u
. Notice the-e
in the mainecho
– Brahim Gaabab May 18 '22 at 21:03echo "$(...)"
. – ilkkachu May 18 '22 at 21:12