I have a requirement where in I need to change the contents of a file say xyz.cfg. the file contains values like:
How about something like:
#!/bin/bash addr=$1 port=$2 user=$3 sed -i -e "s/\(address=\).*/\1$1/" \ -e "s/\(port=\).*/\1$2/" \ -e "s/\(username=\).*/\1$3/" xyz.cfg
$3 are the arguments passed to the script. Save it a file such as
script.sh and make sure it executable with
chmod +x script.sh then you can run it like:
$ ./script.sh 127.8.7.7 7822 xyz_ITR4 $ cat xyz.cfg group address=127.8.7.7 port=7822 Jboss username=xyz_ITR4
This gives you the basic structure however you would want to think about validating input ect.