Shell将计算机内核与用户操作连接起来。用户可以通过这个界面访问到操作系统内核。Shell不但可以将用户命令传递给内核,而且可以调试其他程序、被其他程序调用。
Shell编程是指为Shell编写脚本程序任务。
Linux中的Shell有很多种类,我们主要关注Bash,因为Bash在实际的工作生活中被广泛使用,并且它也是大多数Linux系统默认的Shell。
#!/bin/bash
a=6
b=10
#1
val=`expr $a + $b`
echo "a + b : $val"
#2
echo `date`
#3
printf "%-10s %-8s %-4s\n" name gender heightcm
#4
array_test=(E H P C)
echo "first element: ${array_test[0]}"
#5
if [ $a == $b ]
then
echo "a==b"
else
echo "a!=b"
fi
#6 count=1
while(( $count<=3 ))
do
echo $count
let "count++"
done
#7
for str in 'ehpc is easy hpc'
do
echo $str
done
#8
function echo_hello(){
echo "happy"
}
echo_hello
#9
test(){
echo " $1 !"
echo " $2 !"
echo " $5 !"
echo " ${10} !"
}
test 1 3 5 7 9 11 13 15 17 19
remember
chmod 777 text.txt
from https://www.easyhpc.net