I'm new to bash, and i'm trying to write a script that checks if sudo is installed. And if not, ask if the user wants to install it.
But i'm getting this error (note that x is what i type in response to read
on line 8)
line 9: x: command not found
line 11: x: command not found
I searched for this problem and found this answer, but it does not bring up my problem.
And this is my code:
#!/bin/bash
# Checking for sudo
if ! dpkg-query -l sudo &> /dev/null; then
echo -e "sudo is not installed"
echo -e "sudo is required to continue"
echo -e "install sudo? (y/n)"
read
if "$REPLY" = "y"; then
su -c 'apt install sudo -y' root
elif "$REPLY" = "n"; then
echo -e "aborting setup"
exit
else
echo -e "unknown response, aborting setup"
exit
fi
fi