I'm struggling getting this done. I need to run some commands on my current shell session (no script) and I want to redefine/reset a variable that was defined earlier, but it does not work, see below pls:
# server=`grep "<address>" /etc/file.conf |sed "s/<address>//"`
# echo $server
10.10.10.10
# [ "${server}" == "10.10.10.10" ] && ( sed -i "s/10.10.10.10/10.10.10.20/" /etc/file.conf ; server=10.10.10.20 ; echo $server)
10.10.10.20
# echo $server
10.10.10.10
the variable server does not take from inside of the &&
I've tried export, set, but no way to make this happen. The solution I found was to run the grep command again, but I'm so picky that I'd like to make this happen based on my first thought.
Any ideas?
Thanks!