Actually the man page is more a reference or a reminder for users who already know how things are done. If you look in the section "SHELL GRAMMAR" in the paragraph "Compound Commands" you'll find the description of "if". It says
Code:
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then list is executed. Otherwise, each elif list is executed in turn, and if its exit status is zero, the corre‐
sponding then list is executed and the command completes. Otherwise, the else list is executed, if present. The exit status is the exit status of the last command exe‐
cuted, or zero if no condition tested true.
So in your case
Code:
if apt install kde-wallpapers; then
# commands in case the installation worked
;
else
# commands to execute in case of installation failure
;
fi
A bit earlier in the page - in the paragraph on lists - you can find the description of AND and OR lists: 'command1 && command2' executes command2 only if command1 succeeded, 'command1 || command2' executes command2 only if command1 failed.
A bit later in the page - in the section on Parameter, paragraph on special parameters - you'll find "$?", a parameter (or variable) that holds the exit status of the last command executed (a status of 0 means success, all other values describe some kind of failure) ...
Instead of trying to use the man page for learning the basics - which is not what it's there for - you might want to take a look at http://linuxcommand.org/tlcl.php - a book about the Linux command line by William Shotts, available both in a printed Version and in a free version for download.
Holger
Bookmarks