Appending content of a file to another file before a specific character

Hi there,

i've got a file with this content

[matt@matt01 tmp]$ cat file1
Matt
Mar

The other file has the same number of lines with this content:

[matt@matt01 tmp]$ cat file2
20404=767294
23450=32427

is there a way with either using sed, awk or paste to insert the content of file1 before the "=" character? So I'll end up with this:

20404_Matt=767294
23450_Mar=32427

--- Post updated at 06:29 PM ---

I have found a workaround with paste and awk

paste -d "=" file1 file2 | awk -F "=" '{print$2"("$1")="$3}'
awk -F= 'FNR==NR{f1[FNR]=$0;next} {print $1 "_" f1[FNR], $2}' file1 OFS="=" file2
1 Like
awk '(getline tmp < "file1") { print $1 "_" tmp FS $2}' FS="=" file2
1 Like
awk '!/=/ {line[FNR]="_"$0} /=/ && $1=$1 line[FNR]' file1 FS== OFS== file2