Search code examples
shpacman-package-manager

running an installation command in bash: "n" followed by "Y" without any manual intervention


So on a fresh instance of arch linux, I want to be able to install tzdata from the get-go.

To do so manually, I do this:-

[root@myarch ~]# pacman -S tzdata
:: The following packages should be upgraded first :
    pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n] n

resolving dependencies...
looking for inter-conflicts...

Targets (1): tzdata-2012c-1

Total Download Size:    0.13 MB
Total Installed Size:   5.41 MB

Proceed with installation? [Y/n] Y

As can be seen, I have to first key in n, followed by Y.

How do I run run this in one single line of bash without needing to key in n and Y?

yes n | pacman -S tzdata

gets me pass the first prompt. But I get stuck on the second prompt (obviously).


Solution

  • { echo n ; yes ; } | pacman ...