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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -