Tutorial by Examples

Whitespace matters when assigning variables. foo = 'bar' # incorrect foo= 'bar' # incorrect foo='bar' # correct The first two will result in syntax errors (or worse, executing an incorrect command). The last example will correctly set the variable $foo to the text "bar".
The C standard says that files should end with a new line, so if EOF comes at the end of a line, that line may not be missed by some commands. As an example: $ echo 'one\ntwo\nthree\c' > file.txt $ cat file.txt one two three $ while read line ; do echo "line $line" ; done <...
In most scripting languages, if a function call fails, it may throw an exception and stop execution of the program. Bash commands do not have exceptions, but they do have exit codes. A non-zero exit code signals failure, however, a non-zero exit code will not stop execution of the program. This can...

Page 1 of 1