Get two lists from two variables and combine side by side into one variable.
Suppose you echo "$var1"
you get this output:
a
b
c
d
Suppose you echo $var2
you get this output:
1
2
3
4
I want $var3
to have this exact output:
a 1
b 2
c 3
d 4
How do you do this?
And if you are asking why I want this, when you assign a variable a command or multiple commands, the first command must start and end, then the second command must start and end such that varx=(command1 && command2)
would provide:
a
b
c
d
1
2
3
4
Also this must be accomplished without file input or output. I forgot to add, do not assume the lists are static. In fact, assume the opposite, the lists are dynamic. That is to say one command generates one list and another generates another list. So part of the problem is making sure the output is in sync especially with script buggy software like apt. It gets a little confusing because both apt, aptitude and apt-rdepends can show packages and rdepends (except maybe aptitude). They all different speeds and levels of bugginess, apt being the most buggy. It would be nice to have a function to test program speed (which of the 3 is fastest in showing packages or rdependencies). Anyways, I worked around the problem by using one program to fetch the dependencies (therefore create static list) and another to show the package name and size. Before I was trying to list rdepends and show at the same time, but with different commands thus leading to all sorts of fun problems including sync :) I know see how stupid that was.
As promised here is the script (the 1st was the subject of this question):
RDEPENDS version
ps -A &>> Distro1Analysis.txt && sudo service --status-all &>> Distro1Analysis.txt && \
for z in $(dpkg -l | awk '/^[hi]i/{print $2}' | grep -v '^lib'); do \
printf "\n$z:" && \
aptitude show $z | grep -E 'Uncompressed Size' && \
result=$(apt-rdepends 2>/dev/null $z | grep -v "Depends")
final=$(apt show 2>/dev/null $result | grep -E "Package|Installed-Size" | sed "/APT/d;s/Installed-Size: //");
if [[ (${#final} -le 700) ]]; then echo $final; else :; fi done &>> Distro1Analysis.txt
DEPENDS
ps -A &>> Distro1Analysis.txt && sudo service --status-all &>> Distro1Analysis.txt && \
for z in $(dpkg -l | awk '/^[hi]i/{print $2}' | grep -v '^lib'); do \
printf "\n$z:" && \
aptitude show $z | grep -E 'Uncompressed Size' && \
printf "\n" && \
apt show 2>/dev/null $(aptitude search '!~i?reverse-depends("^'$z'$")' -F "%p" | \
sed 's/:i386$//') | grep -E 'Package|Installed-Size' | sed '/APT/d;s/^.*Package:/\t&/;N;s/\n/ /'; done &>> Distro1Analysis.txt
Both scripts work, however could be written more clearly and optimized to work much faster. However both scripts teach nevertheless. Also, although, I fixed the scripts so they function, to keep compact, I opted not to put into two lists as originally sought; due how commands were originally spitting out the output.