#! /bin/csh
# NEW PASS value will change in every run
set NEW_PASS=`dyanamic generating password on everyrun`
echo $NEW_PASS
There is another conf file where we need to change the above generated password. In new.conf file corresponding line is pass=XYZ, Now above NEW_PASS value should be updated with new.conf file with replcing XYZ. I tried
sed -i -e "s/^pass*/pass=${NEW_PASS}/g" new.conf
But it's not working. Not sure if there is any issues with command syntax.
sedsingle quoted or double quoted? Variables are not expanded in single quotes. There will be a syntax error if the variable contains slashes. Are you running this command on macOS? If on macOS, your use of-iand-etogether will create a backup file callednew.conf-e. Also, regular expressions are case sensitive, andpass*matchespas,pass,passsetc., but not the whole stringpass=or anything thereafter on the same line (it also matches any line saying e.g.old_passor that has any other prefix beforepas). – Kusalananda Jun 17 '21 at 12:09$NEW_PASSif possible, as some values of this variable are bound to cause problems. – Kusalananda Jun 17 '21 at 12:32$NEW_PASSis (or at least if it works with some values and not others). – Kusalananda Jun 17 '21 at 12:43*as if it were a shell wildcard, whereas it has a very different meaning in regular expressions such assedexpects. – AdminBee Jun 17 '21 at 14:39