There is a file named partner like:abcdefghiThere is another conf file like:part=abcvar=xvar=yid=123part=defvar=zid=345and so on...I am making a shellscript which reads line from 'partner' using while loop, then searches the block containing that partner name in conf file using sed. After that, and finally replacing id value (eg: from 123 to 123_1 )using sed and storing the new block in another file.while read -r var || [[ -n $var ]]do sed -n '/part=$var/,/^$/p' conf.cfg | xargs sed 's/id=123/id=123_1/g' >> new.txtdoneWhat am I doing wrong? As it only gives me empty lines of text as output.
Using sed to find and change information in configuration file
shell script;sed
When using variables in arguments of a command, you can't enclose it in simple quotes.Troubleshooting shell scripts, try running your commands one after the other, ... this would help you narrow down your problem.sed -n /part=$var/,/^$/p conf.cfg