You can do this with sed: sed '/actual/{p;s/actual/future/g;}' pg_hba.conf
Once you have checked that the output is good, just add -i to write to file: sed -i '/actual/{p;s/actual/future/g;}' pg_hba.conf