Section 1.0 If statements
Although costs much in terms of cycles.. we can't live without them...
Here is how you quickly
var="NiTrO"
if [ $var = "NiTro" ]; then
echo $var
else
echo "HelloWorld\n"
fi
Section 1.1 Loops
Let's do some BASH loops.. notice this is BASH not sh :)
a quicky for loop
for img in $(ls | grep *.jpg); do echo $img; done
for i in `seq 0 10`; do echo $i; done
i=0; # no spaces
while [ $i -lt 100 ]; do # a space after [
echo $i
let i=i+1
done
# until -- this will do the same as the previous loop
i=0;
until [ $i -gt 10 ]; do
echo $i
let i=i+1
done
Section 1.2 Logical Operators
we love logical operators, which are those weired things used in tests and conditional statements...
For strings... it is very easy
=, !=, <, >, -z (is null), -n (is not null)
Arithmetic
-lt, -le, -gt, -ge, -eq -ne
Ok i'm bored!! enough for today
No comments:
Post a Comment