![]() |
What is fi or "the fi command" in Linux/Unix?
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?
Thanks. |
Re: What is fi or "the fi command" in Linux/Unix?
fi is used in scripts to end a if statement afaik so it will execute the rest of a script.
|
Re: What is fi or "the fi command" in Linux/Unix?
dont know if this helps but i googled it http://linux.byexamples.com/archives/107/if-then-fi/
|
Re: What is fi or "the fi command" in Linux/Unix?
'fi' is simply the sh-style name for 'endif', to finish an 'if' statement. E.g.:
Code:
#!/bin/sh |
Re: What is fi or "the fi command" in Linux/Unix?
Quote:
|
Re: What is fi or "the fi command" in Linux/Unix?
As mentioned "fi" is the end of a "if" statement
if something happens then do something else dont do something fi |
Re: What is fi or "the fi command" in Linux/Unix?
GeraldKo (and anyone else who wondered...) --
regarding the esac reference above: it performs the same function at the conclusion of a case statement. :) |
Re: What is fi or "the fi command" in Linux/Unix?
Quote:
|
Re: What is fi or "the fi command" in Linux/Unix?
Quote:
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. |
Re: What is fi or "the fi command" in Linux/Unix?
There's elif, too:
Code:
if ... ; then |
All times are GMT. The time now is 14:53. |
vBulletin® Version 3.8.8