想删除以$ip变量开头的那一行,这命令该怎么写呢? sed -i '/^'$ip'/d' /etc/hosts 单引号内是sed的作用域,而ip为shell变量,要使变量ip得到解析,要拿到sed作用域外面来。