Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically hit Enter in bash script when asked?

I know that this question is answered many times, but I still can't figure out how to do it. Maybe it's because I don't know the correct keyword to search for.

Using

echo -ne '\n' | enter

doesn't work. My code is:

#! /bin/bash
#Grub-customizer
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
echo -ne '\n' | return
sudo apt-get update
sudo apt-get install grub-customizer
like image 686
Ooker Avatar asked Mar 13 '14 18:03

Ooker


1 Answers

You're supposed to pipe the \n into the command that's going to be receiving it (otherwise it won't ever see it!):

echo -ne '\n' | sudo add-apt-repository ppa:danielrichter2007/grub-customizer
echo -ne '\n' | sudo apt-get install grub-customizer

Now, the right solution here would instead be to use the -y flags instead:

sudo add-apt-repository -y ppa:danielrichter2007/grub-customizer
sudo apt-get install -y grub-customizer
like image 145
Thomas Orozco Avatar answered Nov 07 '22 09:11

Thomas Orozco