[Linux](EN) Use or pass sudo password in shell script
Process file or result of command in while loop line by line in shell script.
Environment and Prerequisite
- Linux base system
 - Bash shell(/bin/bash)
 
Solution
- Use 
-Soption and| 
echo "PASSWORD" | sudo -S apt-get update
- Usage with file
 
cat << EOF > password.txt
> PASSWORD
> EOF
cat password.txt | sudo -S apt-get update
- Use 
--stdinoption and| 
echo "PASSWORD" | sudo --stdin apt-get update
- Usage with file
 
cat << EOF > password.txt
> PASSWORD
> EOF
cat password.txt | sudo --stdin apt-get update