0

Hi,

I'm trying to check if the user that im deleting exist in the database before deleting them, but it does not recognise the id (delID) the second time that i enter the id (even if it is right).

Any suggestion

delete(){
clear
echo "-------------"
echo "DELETE RECORDS"
echo "-------------"
read -p "Please enter staff id that you wish to delete: " delID

indelID=$(grep $delID ~/appraisal/work.db | cut -d":" -f1)
surname=$(grep $delID ~/appraisal/work.db | cut -d":" -f2)
name=$(grep $delID ~/appraisal/work.db | cut -d":" -f3)

while [[ "$(echo $delID | grep -c '^[0-9][0-9][0-9]$')" = 0 || $delID = $inlID ]]
do
read -p "The staff ID entered is incorrect, please try again: " delID
done
echo "Would you like to delete $name $surname from the database? (press y or n)"
read ans

if [[ $ans = y* || $ans = Y* ]]
then
sed -i "/$delID/d" ~/appraisal/work.db
echo "record deleted!"
else [$ans != n ]
menu
fi
read -p "Press return access the main menu " main
menu
}

Thanks

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Pjieter
-1

@Rizzuti:
You tried running the file as root?

sudo script

Edited by Narue: Cleaning up along with spam

Votes + Comments
Report spam, don't reply to it or your posts are likely to be edited/deleted along with the spam.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.