Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
start [2015/08/08 14:39]
bill_thomson [How to....]
start [2019/08/22 13:56] (current)
murugan [Builtin Commands]
Line 2: Line 2:
 ~~DISCUSSION:​off~~ ~~DISCUSSION:​off~~
  
-====== Bash Hackers Wiki Front page ======+====== ​The Bash Hackers Wiki ======
  
 {{keywords>​bash shell linux scripting}} {{keywords>​bash shell linux scripting}}
  
 <WRAP center round box 90%> <WRAP center round box 90%>
-//**__The Bash-Hackers Wiki__**// 
 This wiki is intended to hold documentation of any kind about GNU Bash. The main motivation was to provide //​human-readable documentation//​ and information so users aren't forced to read every bit of the Bash manpage - which can be difficult to understand. However, the docs here are **not** meant as a newbie tutorial. This wiki is intended to hold documentation of any kind about GNU Bash. The main motivation was to provide //​human-readable documentation//​ and information so users aren't forced to read every bit of the Bash manpage - which can be difficult to understand. However, the docs here are **not** meant as a newbie tutorial.
 +
 +This wiki and any programs found in this wiki are free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 +
 +This wiki and its programs are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ​ See the GNU General Public License for more details.
 +
 +You should have received a copy of the GNU General Public License along with this program. ​ If not, see <​http://​www.gnu.org/​licenses/>​.
  
 [[wishes | What would YOU like to see here?]] (outdated and locked, please use the discussions) [[wishes | What would YOU like to see here?]] (outdated and locked, please use the discussions)
  
-**Stranger!** [[http://​wiki.bash-hackers.org/​start&​do=register | Feel free to register]] and edit the contents. There is a [[meta:​need_love|Bash Hackers Wiki needs love page]] that lists some things to do. The registration is only there to prevent SPAM.+**Stranger!** [[http://​wiki.bash-hackers.org/​start&​do=register | Feel free to register]] and comment or edit the contents. There is a [[meta:​need_love|Bash Hackers Wiki needs love page]] that lists some things to do. The registration is only there to prevent SPAM.
 </​WRAP>​ </​WRAP>​
  
Line 49: Line 54:
   * [[howto:​getopts_tutorial]] (//under construction!//​)   * [[howto:​getopts_tutorial]] (//under construction!//​)
   * [[howto:​dissectabadoneliner]] An example of a bad oneliner, breakdown and fix (by ''​kojoro''​)   * [[howto:​dissectabadoneliner]] An example of a bad oneliner, breakdown and fix (by ''​kojoro''​)
 +  * [[howto:​testing-your-scripts | Write tests for ./​your-script.sh]] by using bashtest util 
  
  
Line 55: Line 61:
   * [[scripting:​bashchanges | Bash features overview by version]]   * [[scripting:​bashchanges | Bash features overview by version]]
   * [[syntax:​basicgrammar | Basic grammar rules ]]   * [[syntax:​basicgrammar | Basic grammar rules ]]
-  * [[syntax:​quoting | Quoting and character-escaping]]+  * [[syntax:​quoting | Quoting and character escaping]]
   * [[syntax:​grammar:​parser_exec | Parsing and execution]]   * [[syntax:​grammar:​parser_exec | Parsing and execution]]
   * [[syntax:​words | Some words about words...]]   * [[syntax:​words | Some words about words...]]
Line 106: Line 112:
  
 <WRAP column 46%> <WRAP column 46%>
-^  Declaration commands\\ <wrap lo>​Commands that set and query attributes/​types,​ and manipulate simple datastructures.</​wrap> ​ ^^  Alt  ^  Type  ^+^  Declaration commands\\ <​wrap ​center round lo todo box 80%>​Commands that set and query attributes/​types,​ and manipulate simple datastructures.</​wrap> ​ ^^  Alt  ^  Type  ^
 |[[commands:​builtin:​declare | declare]]|Display or set shell variables or functions along with attributes.| ​ ''​typeset'' ​ |  builtin ​ | |[[commands:​builtin:​declare | declare]]|Display or set shell variables or functions along with attributes.| ​ ''​typeset'' ​ |  builtin ​ |
 |[[commands:​builtin:​export | export]]|Display or set shell variables, also giving them the export attribute.| ​ ''​typeset -x'' ​ |  special builtin ​ | |[[commands:​builtin:​export | export]]|Display or set shell variables, also giving them the export attribute.| ​ ''​typeset -x'' ​ |  special builtin ​ |
Line 114: Line 120:
 |[[commands:​builtin:​unset | unset]]|Unset variables and functions.| ​ -  |  special builtin ​ | |[[commands:​builtin:​unset | unset]]|Unset variables and functions.| ​ -  |  special builtin ​ |
 |[[commands:​builtin:​shift | shift]]|Shift positional parameters| ​ -  |  special builtin ​ | |[[commands:​builtin:​shift | shift]]|Shift positional parameters| ​ -  |  special builtin ​ |
-^  I/O\\ <wrap lo>​Commands for reading/​parsing input, or producing/​formatting output of standard streams.</​wrap> ​ ^^  Alt  ^  Type  ^ +^  I/O\\ <​wrap ​center round lo todo box 80%>​Commands for reading/​parsing input, or producing/​formatting output of standard streams.</​wrap> ​ ^^  Alt  ^  Type  ^ 
-|[[syntax:​keywords:​coproc | coproc]]|Co-processes:​ Run a compound ​command in the background with async I/O.|  -  |  keyword ​ |+|[[syntax:​keywords:​coproc | coproc]]|Co-processes:​ Run a command in the background with pipes for reading ​writing its standard streams.|  -  |  keyword ​ |
 |[[commands:​builtin:​echo | echo]]|Create output from arguments.| ​ -  |  builtin ​ | |[[commands:​builtin:​echo | echo]]|Create output from arguments.| ​ -  |  builtin ​ |
 |[[commands:​builtin:​mapfile | mapfile]]|Read lines of input into an array.| ​ ''​readarray'' ​ |  builtin ​ | |[[commands:​builtin:​mapfile | mapfile]]|Read lines of input into an array.| ​ ''​readarray'' ​ |  builtin ​ |
 |[[commands:​builtin:​printf | printf]]|"​advanced ''​echo''​."​| ​ -  |  builtin ​ | |[[commands:​builtin:​printf | printf]]|"​advanced ''​echo''​."​| ​ -  |  builtin ​ |
 |[[commands:​builtin:​read | read]]|Read input into variables or arrays, or split strings into fields using delimiters.| ​ -  |  builtin ​ | |[[commands:​builtin:​read | read]]|Read input into variables or arrays, or split strings into fields using delimiters.| ​ -  |  builtin ​ |
-^  Configuration and Debugging\\ <wrap lo>​Commands that modify shell behavior, change special options, assist in debugging.</​wrap> ​ ^^  Alt  ^  Type  ^+^  Configuration and Debugging\\ <​wrap ​center round lo todo box 80%>​Commands that modify shell behavior, change special options, assist in debugging.</​wrap> ​ ^^  Alt  ^  Type  ^
 |[[commands:​builtin:​caller | caller]]|Identify/​print execution frames.| ​ -  |  builtin ​ | |[[commands:​builtin:​caller | caller]]|Identify/​print execution frames.| ​ -  |  builtin ​ |
 |[[commands:​builtin:​set | set]]|Set the positional parameters and/or set options that affect shell behaviour.| ​ -  |  special builtin ​ | |[[commands:​builtin:​set | set]]|Set the positional parameters and/or set options that affect shell behaviour.| ​ -  |  special builtin ​ |
Line 127: Line 133:
  
 <WRAP column 46%> <WRAP column 46%>
-^  Control flow and data processing\\ <wrap center round lo todo box 80%>​Commands that operate on data and/or affect control flow.</​wrap> ​ ^^  Alt  ^  Type  +^  Control flow and data processing\\ <wrap center round lo todo box 80%>​Commands that operate on data and/or affect control flow.</​wrap> ​                                                          |^  Alt     ​^  Type             ​
-|[[commands:​builtin:​true | colon]]|"​true"​ null command.| ​ true  |  special builtin ​ | +| [[commands:​builtin:​true| colon]] ​                                                                                                        ​| "​true"​ null command. ​                                   |  true    |  special builtin ​ | 
-|[[commands:​builtin:​source | dot]]|Source external files.| ​ source ​ |  special builtin ​ | +| [[commands:​builtin:​source| dot]]                                                                                                         ​| Source external files. ​                                 |  source ​ |  special builtin ​ | 
-|[[commands:​builtin:​false | false]]|Fail at doing nothing.| ​ -  |  builtin ​ +| [[commands:​builtin:​false| false]] ​                                                                                                       | Fail at doing nothing. ​                                 |  -       ​|  builtin ​         
-|[[commands:​builtin:​continueBreak | continue / break]]|continue with or break out of loops.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​continueBreak| continue / break]] ​                                                                                    ​| continue with or break out of loops. ​                   |  -       ​|  special builtin ​ | 
-|[[commands:​builtin:​let | let]]|Arithmetic evaluation simple command.| ​ -  |  builtin ​ +| [[commands:​builtin:​let| let]]                                                                                                            | Arithmetic evaluation simple command. ​                  ​|  -       ​|  builtin ​         
-|[[commands:​builtin:​return | return]]|Return from a function with a specified exit status.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​return| return]] ​                                                                                                     | Return from a function with a specified exit status. ​   |  -       ​|  special builtin ​ | 
-|[[commands:​classictest | []]|The classic ''​test''​ simple command.| ​ test  |  builtin ​ +| [[commands:​classictest| []]                                                                                                              | The classic ''​test''​ simple command. ​                   |  test    |  builtin ​         
-^  Process and Job control\\ <wrap center round lo todo box 80%>​Commands related to jobs, signals, process groups, subshells.</​wrap> ​ ^^  Alt  ^  Type  +^  Process and Job control\\ <wrap center round lo todo box 80%>​Commands related to jobs, signals, process groups, subshells.</​wrap> ​                                                               |^  Alt     ​^  Type             ​
-|[[commands:​builtin:​exec | exec]]|Replace the current shell process or set redirections.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​exec| exec]] ​                                                                                                         | Replace the current shell process or set redirections. ​ |  -       ​|  special builtin ​ | 
-|[[commands:​builtin:​exit | exit]]|Exit the shell.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​exit| exit]] ​                                                                                                         | Exit the shell. ​                                        ​|  -       ​|  special builtin  ​
-|[[commands:​builtin:​trap | trap]]|Set signal handlers or output the current handlers.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​kill| kill]] ​                                                                                                         | Send a signal to specified process(es) ​                 |  -       | builtin ​          
-|[[commands:​builtin:​times | times]]|Display process times.| ​ -  |  special builtin ​ | +| [[commands:​builtin:​trap| trap]] ​                                                                                                         | Set signal handlers or output the current handlers. ​    ​|  -       ​|  special builtin ​ | 
-|[[commands:​builtin:​wait | wait]]|Wait for background jobs and asynchronous lists.| ​ -  |  builtin ​ +| [[commands:​builtin:​times| times]] ​                                                                                                       | Display process times. ​                                 |  -       ​|  special builtin ​ | 
- ​Interactive\\ <wrap center round lo todo box 80%>​History,​ programmable completion, directory stack.</​wrap> ​ ^^  Alt  ^  Type  ^+| [[commands:​builtin:​wait| wait]] ​                                                                                                         | Wait for background jobs and asynchronous lists. ​       |  -       ​|  builtin ​         
 +                                                                                                                                                                                                  |^  Alt     ​^  Type             ​^
 </​WRAP>​ </​WRAP>​
 <WRAP clear></​WRAP>​ <WRAP clear></​WRAP>​
Line 197: Line 204:
   * [[http://​www.opengroup.org/​austin/​ | The Austin Group]] - [[ http://​dir.gmane.org/​gmane.comp.standards.posix.austin.general | List archives ]], [[ http://​austingroupbugs.net/​main_page.php | Bug tracker ]]   * [[http://​www.opengroup.org/​austin/​ | The Austin Group]] - [[ http://​dir.gmane.org/​gmane.comp.standards.posix.austin.general | List archives ]], [[ http://​austingroupbugs.net/​main_page.php | Bug tracker ]]
   * [[http://​cfajohnson.com/​shell/​cus-faq.html | comp.unix.shell FAQ]]   * [[http://​cfajohnson.com/​shell/​cus-faq.html | comp.unix.shell FAQ]]
 +
  
 === Documentation / Reference === === Documentation / Reference ===
Line 214: Line 222:
   * [[http://​www.computerworld.com.au/​article/​279011/​a-z_programming_languages_sh | Interview with Steve Bourne]] • [[https://​www.youtube.com/​watch?​v=2kEJoWfobpA | Stephen Bourne - BSDCan 2015 keynote]]   * [[http://​www.computerworld.com.au/​article/​279011/​a-z_programming_languages_sh | Interview with Steve Bourne]] • [[https://​www.youtube.com/​watch?​v=2kEJoWfobpA | Stephen Bourne - BSDCan 2015 keynote]]
   * [[http://​news.slashdot.org/​story/​01/​02/​06/​2030205/​david-korn-tells-all | Interview with David Korn]]   * [[http://​news.slashdot.org/​story/​01/​02/​06/​2030205/​david-korn-tells-all | Interview with David Korn]]
 +  * [[https://​www.youtube.com/​watch?​v=bKzonnwoR2I | Kernighan on the Unix pipeline (computerphile video)]]
   * Linux in general, with some shell related stuff: [[http://​www.cyberciti.biz/​ | nixCraft: Linux Tips, Hacks, Tutorials and Ideas]]   * Linux in general, with some shell related stuff: [[http://​www.cyberciti.biz/​ | nixCraft: Linux Tips, Hacks, Tutorials and Ideas]]
 +  * Linux tutorials, guides and how-tos: [[https://​www.rosehosting.com/​blog/​ | RoseHosting Blog]], [[https://​www.rosehosting.com/​blog/​script-install-wordpress-on-a-debianubuntu-vps/​ | bash script for installing WordPress]] and some [[https://​www.rosehosting.com/​blog/​basic-shell-commands-after-putty-ssh-logon/​ | basic shell commands]]
   * [[misc:​bashphorisms | Bashphorism list from the Bash IRC channel on Freenode]]   * [[misc:​bashphorisms | Bashphorism list from the Bash IRC channel on Freenode]]
   * [[misc:​shell_humor | Some more or less funny commandline stuff]]   * [[misc:​shell_humor | Some more or less funny commandline stuff]]
 +  * [[https://​thishosting.rocks/​how-to-enable-ssh-on-ubuntu/​ | How to Enable SSH on Ubuntu Tutorial]]
 ==== Bash Libraries (needs review) ==== ==== Bash Libraries (needs review) ====
  
Line 248: Line 258:
 Visit us in ''​irc.freenode.net'',​ channel ''#​bash''​ ;-) Visit us in ''​irc.freenode.net'',​ channel ''#​bash''​ ;-)
  
-If you have critiques or suggestions,​ please feel free to send a mail using the contact form on the right. ​<​del>​If you have quick suggestions,​ you can also use the [[wishes]] (editable by everyone!).</​del> ​Note that there is a discussion ​platform ​below every article ​page.+If you have critiques or suggestions,​ please feel free to send a mail using the contact form on the right. Note that there is a simple ​discussion ​option ​below every article.
  
 Please also see the [[user:​thebonsai:​imprint | imprint]] if you have problems with the site and its contents (legality, ...)! Please also see the [[user:​thebonsai:​imprint | imprint]] if you have problems with the site and its contents (legality, ...)!
  • start.1439044747.txt
  • Last modified: 2015/08/08 14:39
  • by bill_thomson