Beta
sed 's/pattern/change/g'
to replace strings.
backtick: `command` shells run command line and SDTOUT in a variable.
equivalent to $(command)
Array in bash
declare -a array
array=(1 2 3)
- array[@] to return all elements
- #array[@] to return length of array
- can overwrite elements using index accessing
- slicing array[@]:N:M _ N = start, M = number of elements
- appending array+=(elements)
Associate array -A
- array=([key]=value [key]=value)
- accessing key using !array[@]
- appending array[key]=value
ìf []; then
else
fi
can use both arithmetic special notation with [] or (())
special conditional flags:
- -e if file exists
- -s if file exists and size > 0
- -r if file exists and readable
- -w if file exists and writeable
&& AND ; || OR
brace expansion in for loop
- if i in {x..y..z}
- do
-
something
- done
3 expression syntax in for loop
- for ((x=1;x<4;x+=1))
- do
-
something
- done
glob expansion for file
- for file in books/*
- do
-
something
- done
crontab -e to edit