Skip to content

POSIX Shell

Pass user arguments without user intervention

Source

Sometimes, commands provide an option to avoid any user interaction so that they can be run unattended (e.g. -y for apt).

When this isn't the case, you can pipe to stdin instead:

# Using pipes and echo
echo -e "yes\nno" | your_command
# Using a file
echo -e "yes\nno" > file.txt
your_command < file.txt
# Using a HEREDOC (not POSIX)
your_command << INPUT
yes
no
INPUT
# Using a HERESTRING
your_command <<< $'yes\nno'