Closing.
]]>the best I came up with is this:
echo "y" | sudo pacman -Scc \n echo "Y"
... all I am attempting to do is learn/understand the command line more.
Then this example can be useful. The difference between the two `echo "y"` commands is that the output of only one of them is sent to the stdin of the pacman command. The second `echo "y"` simply runs on it's own *after* pacman is done and has exited. As a first incremental improvement for instructional purposes, you could do this:
( echo "y"; echo "y" ) | sudo pacman -Scc
This creates a subshell (the parentheses) within which two echo "y" commands are run. The output of that entire subshell is sent to pacman's stdin, so pacman now gets two "y"s in a row which will accomplish what you were trying to do (though I'm making no statement here on whether that is worth doing).
Now creating a subshell just to run two sequential echo commands is a bit silly, so we can get rid of that and just use one echo command that outputs the two "y"s each followed by a newline. This will have the same effect as the example above (also acheiving what you intended to do):
echo -e "y\ny" | sudo pacman -Scc
Now, given that others have realized there may be times where you would just want to generate a string of "y"s followed by newlines to feed as input to another process, a command was created to do just that: it creates a string of "y"s followed by newlines as long as it's output is connected. So this too will do the same as the above:
yes | sudo pacman -Scc
before anyone gets mad and starts insulting me
]]>
Also see man pacman (--noconfirm option)
]]>sudo pacman -Scc
the following two prompts would automatically be answered with "yes," but I cannot figure out how to do so; thus far, I have only been successful in getting the first prompt being automatically answered. After trying different methods and reading a few MAN pages, the best I came up with is this:
echo "y" | sudo pacman -Scc \n
echo "Y"
which produces the following output:
[europa@Nemesis ~]$ ./Scc.sh
Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove ALL files from cache? [y/N] y
removing all files from cache...
Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] Y
[europa@Nemesis ~]$
There is no confirmation in the second prompt of unused sync repositories being removed. However,
sudo pacman -Scc
returns the following output:
[europa@Nemesis ~]$ sudo pacman -Scc
Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove ALL files from cache? [y/N] y
removing all files from cache...
Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] Y
removing unused sync repositories...
[europa@Nemesis ~]$
Now, I know this may seem like a weird question, so before anyone gets mad and starts insulting me, I'd like to mention that all I am attempting to do is learn/understand the command line more, as I have fell completely in love with Arch since switching over from Ubuntu a couple years back.
Thank you in advance for your help, and have a great day.
]]>