About bash functions Also called Shell Functions Once a function is defined, it is used like a "regular" command Shell functions are executed in the current shell context; no new process is created to interpret them. Function Syntax Functions are declared using this syntax: 1fname () compound-command [ redirections ] 2 …
Read MoreAbout Parameter Expansion This post is based on th shell parameter expansion documentation . The ‘$’ character introduces several expansions: parameter expansion command substitution arithmetic expansion Parameter expansion mainly replaces a parameter reference with its value. When we're talking about shell parameters …
Read MoreAbout tilde expansion This post is based on the bash tilde expansion documentation. Let's say that you enter several letters, and them the ~ (tilde) character. If non of the letters are quoted, then bash will try to treat these letters as a login name. It will then try to replace the tilde expression with the home …
Read MoreAbout Brace Expansions This post is based on the documentation of bash brace expansion . Brace expansion is a mechanism that creates strings The basic syntax is: optional preanble (an opening string) a series of comma-separated strings or a sequence expression between a pair of braces optional postscript (a closing …
Read MoreShell Operation Covered here in bash documentation. The shell reads its input from one of these: an input from a file from a string supplied as an argument to the -c invocation option from the user’s terminal Breaks the input into words and operators, obeying the quoting rules described in Quoting These words (called …
Read MoreBASH Arrays See here . Indexed arrays 1names[0]=Yoesf 2names[1]=David 3echo $names # will show: Yosef 4echo ${names[1]} # will show: David Assigning complete arrays. This is done by surounding a list of word with parentheses: 1-> girlz=(Betty Liza Jane) 2-> echo ${girlz[2]} 3Jane 4-> echo ${girlz} 5Betty 6-> or even: …
Read MoreDoing logic with [[ and ]] (this topic is covered in the bash manual here ) Return a status of 0 or 1 depending on the evaluation of the bash conditional expressions example 1: is this a file? 1$> 2$> ls -l 3total 4 4-rw-rw-r-- 1 osboxes osboxes 6 Jan 21 08:39 myfile 5$> 6$> [[ -f myfile ]] 7$> echo $? 80 9$> [[ -f …
Read MorePipelines (this is covered in the bash manual here ) A pipeline is a sequence of one or more commands separated by one of the control operators: | or |& The output of each command in the pipeline is connected via a pipe to the input of the next command. (if you want you can read more about pipes ) These could be both …
Read MoreIntroduction intro Hello World Parameters Special Parameters File Streams Bash Logic 1: pipelines and lists Bash Logic 2: Doing logic with [[ and ]] Bash Arrays Bash Expansions: About Shell Expansions Brace Expansion Tilde Expansion parameter and variable expansion command substitution arithmetic expansion is base on …
Read Morestreams In UNIX, many things take the form of a stream of bytes. Real files are like that, because we can read the as a stream of bytes. Each process see a private list of streams that the process can access There is a number for each stream used: 0,1,2,3,4…. These numbers are called file descriptors The first 3 …
Read More