shell add & test & echo
戚默
2023-12-01
====================================================================================
# Shell Program to Add Two Numbers
clear
echo "Enter first number: "
read a
echo "Enter second number: "
read b
c=`expr $a + $b`
echo "Sum = $c"
====================================================================================
Shell test
Syntax: test prerequisite && statement1 || statement2
Note: if prerequisite is true, then execute statement1, otherwise execute statement2
====================================================================================
[shengshu@cdling21 ~]$ echo -n "aaa"
aaa[shengshu@cdling21 ~]$
[shengshu@cdling21 ~]$
[shengshu@cdling21 ~]$ echo "aaa"
aaa
[shengshu@cdling21 ~]$
[shengshu@cdling21 ~]$ echo "aaa\n"
aaa\n
[shengshu@cdling21 ~]$
[shengshu@cdling21 ~]$ echo -e "aaa\n"
aaa
[shengshu@cdling21 ~]$
====================================================================================