Note that a "join" (mentioned in the question title) is a specific operation where one data set is used to extract data from another data set (a relational join operation). This may be done with the
join utility (or with a short
What you want to do is a data extraction and a merge. This is well explained by you in the question text.
Assuming you have the
bash shell, the contents of the first column of each file can be extracted using
cut, and then merged with
= as a delimiter using
$ paste -d '=' <(cut -d ' ' -f 1 File-1) <(cut -d ' ' -f 1 File-2)
<(...) (process substitution) will be replaced with the name of a temporary file from where the output of the
cut command inside the substitution will be available for
paste to read.
You can then merge this into a single comma-delimited line like so:
$ paste -d '=' <(cut -d ' ' -f 1 File-1) <(cut -d ' ' -f 1 File-2) | paste -d ',' -s -
If you require spaces after each comma,
sed may be used:
$ paste -d '=' <(cut -d ' ' -f 1 File-1) <(cut -d ' ' -f 1 File-2) | paste -d ',' -s - | sed 's/,/, /g'
A=5.4, B=7.4, C=9.4
Note that I have assumed that the empty lines in the question is not actually part of the data files. You may want to pre-process the data with
sed '/^[[:blank:]]*$/d', which would delete any lines that are empty or that only contains spaces and/or tabs.
See also the manual for
man cut and