I am trying to learn bash scripting. I am working on a practical problem and at one point I need to add a line to a file which requires
root permission to write.
The code looks like this:
# some code echo "add this line to the code" >> fileName # some code
Is it possible to somehow make the script ask for the root password, validate the password, and on successful authentication modify the file? The script should then return to the user mode and continue the command execution.