Session contents

Text processing with sed

  • Use of ! for negation
  • Use of -n, -i and -f flags
  • Use of g, p, and w commands
In [ ]:

Construction of shell script

  • Review of steps
In [ ]:

Variables

  • Variables ${var}
  • Length of variable ${#var}
  • Removing substrings ${var#}, ${var##}, ${var%}, ${var%%}
  • Pattern substitution ${var/p/r}, ${var//p/r}
  • Prefix and suffix substitution ${var/#p/r}, ${var/%p/r}
  • Use of declare with -i, -r attributes
In [ ]:

Arrays

  • Index and associative arrasys with decalre -a, declare -A
  • Indexing with $arr, ${arr[0]}, $arr[@]
In [ ]:

Conditionals

  • tests with [[]] and (())
  • test file operators
In [ ]:

Branching

  • if
if CONDITION then;
  commands
fi
In [ ]:

  • case
case EXPR in
PATTERN)
  commands ;;
Pattern
  commands ;;
esac
In [ ]:

Looping

  • for type 1
for EXPR in Sequence
do
  commands
done
In [ ]:

  • for type 2
for (( i=0; i<n; i++ ))
do
  commands
done
In [ ]:

  • while
while Condition
do
  commands
done
In [ ]:

  • until
until Condition
do
  commands
done
In [ ]:

Process control

  • &, fg and Ctrl-z bg
  • ps, ps -a, ps -e
  • jobs
  • kill and kill signals man kill, kill -l, man signal
In [ ]: