Shell语法
expr命令
返回的是std out 1为真 0 为假
#! /bin/bash
array=(yxc acwing lkx 1)
a=4
b=3
echo "a + b = `expr $a + $b`"
echo "a - b = `expr $a - $b`"
echo "a * b = `expr $a \* $b `"
echo "a / b = `expr $a / $b`"
echo "(a + 1) * (b + 1) = `expr \( $a + 1 \) \* \( $b + 1 \)`"
~
~
~
read命令
#! /bin/bash
read -p "What's your name?" -t 5 name
echo Hello, $name
echo命令
# -e 开启转义
echo -e Hello\nWorld!" #\c是不换行
test命令
返回的是exit code 0为真 1为假
输出到文件指定文件中
echo "Hello World" > output.txt
echo "THE FIRST DOCUMENT" > output.txt