Hey, it may be a simple question for you, I try to create script with dialog witch need to change a file in my case is eth configuration file. The problem occurs when in file is for example "IPADDR=" becouse I use dialog --menu I have got error.
The script looks like
Code:
eth0=/conf-file-eth0
items=$(awk -F\= '{print $1,$2}' $eth0)
dialog --title "Eth0" \
--menu "Edit :" 0 0 0 $items 2> $tmpfile1
When line in config file is like "IPADDR=1.1.1.1" then script works good but when is "IPADDR=" error is due to missing argument for dialog. How can I add "IF" function or something else to make it work ? for example i would like to "IF" function add "1.1.1.1" for $2 when it is blank in the configuration file.
I tried something like that
Code:
items=$(awk -F\= '{ if [ $2=="" ]; then
$2="0.0.0."
print $1,$2
else
print $1,$2
fi }' $eth0 )
But i know is wrong.
Thanks for your help