linux - Unix: replace variable in file a with value in file b -
i have 2 files in linux, in file there variables these:
${version} ${software_producer}
and values of these variables stored in file b:
version=1.0.1 software_producer=luc
now how can use command replace variables in file values in file b? sed
able task? thanks.
a simple bash
loop suffice:
$ cat file 'a' has variable ${version} , has also: ${software_producer} $ cat b version=1.0.1 software_producer=luc $ cat script.bash #!/bin/bash while read line || [[ -n "$line" ]] key=$(awk -f= '{print $1}' <<< "$line") value=$(awk -f= '{print $2}' <<< "$line") sed -i 's/${'"$key"'}/'"$value"'/g' done < b $ ./script.bash $ cat file 'a' has variable 1.0.1 , has also: luc $
Comments
Post a Comment