Here, we have two files. we need to copy a key from file 1 and need to replace in file 2 with specific string "key" using sed command. we tried with below commands:
sed -e '3 /key/{r file1' -e 'd}' file2
sed -n "3 s/key/$(cat file 1 |grep ^Key|cut -d ' ' -f2)/" file2
File 1
ABCD
EFGH
Key: qvUkD6QaFBA1jYEpynivMoQx+9V71F4+fdn1TIUKPBNny/3zCnjihd1mwxZg==
File 2
IJKL
MNOP
secret key;
MNOP
Expected result:
IJKL
MNOP
secret qvUkD6QaFBA1jYEpynivMoQx+9V71F4+fdn1TIUKPBNny/3zCnjihd1mwxZg==;
MNOP