User Tools

Site Tools


bash

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bash [2020/08/12 17:20] – [set options] shawnbash [2020/08/12 19:07] (current) – [Functions] Adds tips shawn
Line 1: Line 1:
 +
 +''#!/usr/bin/env bash'' - Use ''bash'' found in the environment path. Protects against not knowing where user's ''bash'' is installed.
  
 ====== set options ====== ====== set options ======
Line 24: Line 26:
   * ''$IFS'' - Internal/input field separator (defaults to combo of space, newline and tab)   * ''$IFS'' - Internal/input field separator (defaults to combo of space, newline and tab)
  
 +====== Functions ======
 +
 +Declaring a function (needs to happen before use):
 +
 +''function <function_name> { ... do things ... }''
 +
 +- or -
 +
 +''<function_name>() { ... do things ... }''
 +
 +  * Nothing ever goes inside parentheses.
 +  * Passed parameters can be accessed with ''$1''..''$n''.
 +
 +====== Tips ======
  
 +  * [[https://stackoverflow.com/a/16496491|Use getopts to parse commandline options]].
bash.1597252807.txt.gz · Last modified: 2020/08/12 17:20 by shawn

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki