Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Bash - what's the use of "fi ;;"?

Writer Matthew Harrington

I have been searching everywhere for an explanation. Here's a real example taken from the apt-fast.sh script:

if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)" read ops case $ops in y) if apt-get install axel -y --force-yes then echo "axel installed" else echo "unable to install the axel. you are using sudo?" ; exit fi ;; n) echo "not possible usage apt-fast" ; exit ;; esac
fi

What's the use of "fi ;;" in the middle of the if block?

2

4 Answers

fi closes the if statement, while ;; closes the current entry in the case statement.

The fi is to close the if-block in the y) case statement and the ;; is used to end the y) case.

fi terminates the preceding if, while ;; terminates the y) case in the case...esac.

fi closes the if statement opened 3 lines up. ;; closes the case opened by y).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy