In the script below second & third line are working but not the first and fourth. The reason is because I am replacing the whole line, I actually only need to replace what's to the right of the '=' sign. Any idea on how I can accomplish this in sed? Thanks.

# example: ./configure input-file, SSID, IP, device-name, gateway, frequency
#
#
FILE=${1}
SSID=${2}
IP=${3}
DEVICE=${4}
GATEWAY=${5}

sed -e "s/\(wireless\.1\.ssid=\).*/${SSID}/g"           \
    -e "s/192\.168\.1\.20$/${IP}/g"                     \
    -e "s/\(NanoBridge M.\)/${DEVICE}/g"                \
    -e "s/\(route\.1\.gateway=\).*/${GATEWAY}/g" ${FILE} > /home/garrett/Desktop/NEW-CONFIG.txt
#END#

I am not very good with sed as well, but what always helps me in this case is google :)
here is an example I just found there:

This will replace /tmp/tmp/... with aaa:

$ sed 's/(.=)[^ ] (.*)/\1 aaa \2/g' <<< "-Djava.util.logging.config.file=/tmp/tmp/tmp/config bla.bla"
-Djava.util.logging.config.file= aaa bla.bla
It "saves" anything up to = in \1. Then fetches everything up to an space. Finally "saves" the rest of the string in \2.

The replacement is done by echoing \1 + "new string" + \2.

It seems closest to your problem. Hope it helps rewriting your own lines. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.