You are on page 1of 1

BASH

File header *=, division / /=, exponentiation **, read var : input line
#! /bin/bash modulo % %= read –n 1 var : input 1 character
. script_init_template If
Stop script if [ “$var” = “string” ] Create Function
exit 1 then function fname(){
Parameters Count command(s) arg1=$1 # commands
if [ "$#" -ne 2 ]; then elif [ $var != ‘string’ ] }
echo "Illegal number parameters" then echo $arg1 # return
exit 1 command(s)
fi else fname2(arg1,argN){
Assginment command(s) commands
# comment fi }
var=26 # NO SPACE Operations Date
list={1..10} string: = != -z (empty) -n (not empty) $ date +"%m-%d-%y"
((Yn=Yn+1)) numbers : -lt -le -gt -ge -eq -ne ' Error handling (not stopping)
String if [ "$int"-le "$int2" ]; then trap '' ERR # Job will not stop by error
get last 3 char "${value1:($ logical operators : and &&, or || command(s)
{#value1}<3?0:(-3))}" float script_init_template # Switch backON
strip last 3 char if (( $(echo "$result1 > $result2" | bc Split
"${value1::${#value1}-3}" -l) )); then mystring="192.168.1.1,UPDOWN,Lin"
first word exist IFS=',' read -a myarray <<<
echo "$line | awk '{print $1;}' " [ -z “$var” ] exist "$mystring"
Lowercase str=`echo “$str”| awk [ ! –z “$var” ] not empty echo "IP: ${myarray[0]}"
‘{print tolower ($0)}` of str=$(str,,) re=’^[0-9]+$’ [[ $var =~ $re ]] number Print word n [1 … ]
uppercase str$(str^^) Case select awk '{print $1}' # 1st word
Split string case string1 in awk '/start/ {print $1}' # only start
IFS=’;’ read –ra out <<< “$in” str1)
value=`echo $1 | sed 's/_/ /g' | sed command(s)
's/,/ /g'`` str2 | str3 )
Search command(s)
>cat filename | grep "\regel1\|regel2" *)
>grep -v "regel" # grep NOT command(s)
Replace _ en , naar space esac
>cat 0172_cust_stitch_4x4mm.log | Loop for
grep "cal drift" | sed 's/_/\t/g' | sed for (( n=0; n<10;n++))
's/,/\t/g' > a.a do
>sed -i -e 's/search/replace/g' test.txt echo $n
Remove line withfor a line, done
>cat 0172_cust_stitch_4x4mm.log |
sed -e '/! absolute frequency/d' > a.a for arg in “a” “b” “c”
line start with word field remove /n do
> cat file | sed '/^field/{N;s/\n//;}' echo $arg
Calculate dec done
antw=$(echo "scale=9; $current * Loop while / until
100000 / $dose / $freq " | bc ) while [ “$var” -lt “$varmax” ]
Round do
antw=$(echo $antw | awk '{printf(" $var++ # commands
%.1f\n",($1 * 10 + 0.5 ) / 10)}' ) done
Arithmetic operators Output / Input Screen
plus + +=, minus - -=, multiplication * echo “text”
echo –n “text” : one line

You might also like