View Single Post
Posts: 263 | Thanked: 679 times | Joined on Apr 2008 @ Lyon, France
#9
Originally Posted by GeraldKo View Post
fi shows up in scripts, and I'm finding it surprisingly hard to get a good explanation of what fi is doing in them. Is it a command? Is it short for something? What does it do?
Hi,

You already got the answer - fi ends an if, much like endif does in other languages (some would say endif would have been better for bash too).

There are four main conditional statements in shell scripts:
if... ; then...; else...; fi
for ...; do...; done
while...; do...; done
and

case ... in
...
esac

You can see that if ends in fi, and case in esac. for and while both use the more understandable do...done convention which is appropriate for loops.