【发布时间】:2016-12-10 09:56:47
【问题描述】:
使用 sed 我可以删除命令提示符内的一行代码。当我在 bash 脚本中使用它并使用变量时,它不会删除它。
function remove_user {
echo "Input user you would like to delete"
read rui
if grep -q $rui database.txt ;
then
echo "Are you sure yu want to delete this user?"
echo "(Y/N)"
read input3
if [ $input3 == "Y" ] || [ $input3 == "y" ] ;
then
sed -i '/"$rui"/d' ./databse.txt
echo "User Deleted"
echo "returning to the main menu..."
echo "$rui"
#sleep 1 ; clear
elif [ $input3 == "N" ] || [$input3 == "n" ] ;
then
echo "returning to main menu..."
sleep 1 ; clear
else
echo "input invalid"
echo "returning to main menu..."
sleep 1 ; clear
fi
else
echo " user not found"
echo "returning to main menu..."
sleep 1 ; clear
fi
我的数据库是这样的
Larry:Larry@hotmail.com:Larry Bob:ATC:4.0
不确定是什么问题,因为代码不能与变量一起工作
【问题讨论】: