I´m starting to use Ubuntu as my secondary OS and I´m creating a script which writes the current IP configuration in a file using redirection (with the command $sudo ifconfig -a > /etc/scripts/current-ipaddress
) and the next thing I want to do is using one of the values written in that external file for the next command, if possible.
For example, lets say I run $sudo ifconfig -a > /etc/scripts/current-ipaddress
and the IP address for eth0 is 192.168.1.203 and the next thing I want to do is making this IP the static one using the command $sudo ifconfig eth0 x.x.x.x
. The idea is substituting this x.x.x.x with the real IP (which will be extracted from the file it was written using redirections previously). How can I make this work?