Hello,
I want to find the "IP-OF-SERVER" in /etc/squid/squid.conf And replace it with The IP of server.
I know this command returns the IP of server :
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
And I can replace with sed. :
sed -i 's/IP-OF-SERVER/#REPLACEMENT/g' /etc/squid/squid.conf
How I can combine the above commands together so that it replaces IP-OF-SERVER phrase with the ip of server automatically ?
Sometimes the code :
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
returns more than 1 ip if the server has more than 1 ip.
I just want to replace IP-OF-SERVER phrase with the first ip in list.
Best Regards