Bash 在文本文件中返回我的变量为空
Bash returning my variable empty in text file
我正在尝试制作简单的 bash,它将找到我的 IP,然后在 .txt 模板中更新它。当我 运行 bash 我的文件充满了空白点而不是 IP 地址。
alias wanip='curl -s http://whatismijnip.nl |cut -d " " -f 5'
wanip
sed -i -e "s/${ip}/"$wanip"/" config.txt
试试这个:
wanip="$(curl -s http://whatismijnip.nl |cut -d " " -f 5)"
sed -i -e "s/${ip}/"$wanip"/" config.txt
我想 $ip 是没有变量的。
我正在尝试制作简单的 bash,它将找到我的 IP,然后在 .txt 模板中更新它。当我 运行 bash 我的文件充满了空白点而不是 IP 地址。
alias wanip='curl -s http://whatismijnip.nl |cut -d " " -f 5'
wanip
sed -i -e "s/${ip}/"$wanip"/" config.txt
试试这个:
wanip="$(curl -s http://whatismijnip.nl |cut -d " " -f 5)"
sed -i -e "s/${ip}/"$wanip"/" config.txt
我想 $ip 是没有变量的。