Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bash (Unix shell)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Control Structures === <!-- '''+++ <code>if</code>''' '''+++ <code>case</code>''' '''+++ <code>for</code>''' '''+++ <code>for ((</code>''' '''+++ <code>while</code> and <code>until</code>''' '''+++ <code>&&</code> and <code>||</code>''' --> Bash supplies "conditional execution" command separators that make execution of a command contingent on the [[Exit status|exit code]] set by a precedent command. For example: <syntaxhighlight lang="bash"> cd "$SOMEWHERE" && ./do_something || echo "An error occurred" >&2 </syntaxhighlight> Where {{code|./do_something}} is only executed if the {{code|cd}} (change directory) command was "successful" (returned an exit status of zero) and the {{code|echo}} command would only be executed if either the {{code|cd}} or the {{code|./do_something}} command return an "error" (non-zero exit status). For all commands the exit status is stored in the special variable <code>$?</code>. Bash also supports {{code|2=bash|if ...;then ...;else ...;fi}} and {{code|2=bash|case $VARIABLE in $pattern)...;;$other_pattern)...;; esac}} forms of conditional command evaluation. <!-- === Boolean Testing === '''+++ <code>test</code> Built-In and Binary''' '''+++ Single Bracket <code>[</code> Built-In and Binary''' '''+++ Double Bracket <code>[[</code> Built-In (and no Binary)''' --><!-- === Pipelines === --><!-- === Subshells === '''+++ Standard Subshells <code>(...)</code>''' '''+++ Command Substitutions <code>$(...)</code>''' '''+++ Pipelines (again) <code>| ... |</code>''' --><!-- === Signals === -->
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)