Tuesday 29 April 2014

Bash Shell Basic

Bash Shell is universally used in Linux Programming, especially in Testing and Evaluation.

Basically, Bash Shell can be used in 3 different ways:
1) interactive shell
2) shell scripting
3) interactive session

Key concepts in Shell
1) Pipeline A | B : the output of A turns to be the input of B.
2) Redirection > and >>: Use ">" to overwrite any existing file, use ">>" to append to any existing file. In both cases, if no file exists, one is created.
3) command processor: #!/bin/bash
   It is the path of the executable bash. 
4) execute mode: chmod 755 ***.sh
5) Branching: if []/then-else-fi
6) Loops and Repetition:  for [] do XXX done; while [] do XXX done;
7) Value $ : get the value of a variable.
8) read & select
9) string operations
10) array operations
11) function with parameters
    function test {
      $1
      exit;
    }
12) critical commands:
   file, find, grep, pwd, sort, whereis, date, ls, echo, 

No comments:

Post a Comment