echo "Hello!"
echo "Enter your name"
read name
echo "Your name is $name"
echo "Choose color"
select color in red green blue white
do
break
done
echo "You chose $color"
for name in bob tom harry
do
echo "Hello $name"
done
for i in {1..10}
do
echo "$i"
done
for i in {1..10..2}
do
echo "$i"
done
echo -e "Guess number:\c"
read guess
if [ $guess = 6 ]
then
echo "Correct"
elif [ $guess != 6 ]
then
echo "False"
fi
colors=(red blue green yellow)
for color in ${colors[*]}
do
echo "$color"
done
string="Ali"
echo $string # Ali
string2=${string:0:1}
echo $string2 # A
function hello {
echo "Hello"
}
hello # Hello
function hello {
echo "Hello $1"
}
hello "Ali" # Hello Ali
function hello {
echo "Hello $1 and $2"
}
hello "Ali" "Reza" # Hello Ali and Reza
X="global"
function hello {
echo "Hello"
local VAR="Hi"
echo $VAR # Hi
echo $X # global
}
hello
echo $VAR # (You'll see it does not actually outputs the variable)
echo $X # global
file="test.txt"
while read line; do
echo $line
done < $file
file="test.txt"
echo "this is a test">>$file
cat $file
file="test.txt"
if [ -f $file ]; then
echo "File exists, removing"
rm -r $file
fi
echo "this is a test">>$file
cat $file