Reputation:
I would like to write a script that automates the execution of
sudo apt-get remove ffmpeg x264 libvpx libav-tools-dev libx264-dev
.
This command displays at the middle of the execution: Would you like to continue [Y / n]?
I want my script to execute without having to ask me to type "Y" to continue.
I added just after this command: echo -e "Y\r"
, but it is not considered?
#!/bin/bash
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
echo -e "Y\r"
Upvotes: 1
Views: 2602
Reputation: 102016
The most general way of automatically answering these questions is to use the yes
utility and pipe it into whatever other program is asking them. e.g.
yes | sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
However, as @Rohan says, in this case apt-get
has equivalent functionality built in, so use that instead.
(NB. you can customise the string yes
outputs. E.g. one could answer "n" to every question like:
yes n | sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
)
Upvotes: 8
Reputation: 53316
Specify -y
to your apt-get
command:
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
From apt-get --help
-y Assume Yes to all queries and do not prompt
Upvotes: 8