1、用shell显示当前日期,时间,用户名和当前工作目录
#!/bin/bash
#写一个shell脚本来得到当前的日期,时间,用户名和当前工作目录
echo -n "当前日期为:"
date | awk '{print $1,$2,$3,$4}'
echo -n "时间为:"
date | awk '{print $5}'
echo -n "用户名为:"
whoami
echo -n "当前工作目录为:"
pwd
2、传入两个数字,然后对这两个数字进行加法运算
#!/bin/bash
#通过外面输入两个数字,判断个数是否正确,然后对这两个数字进行加法运算
if [ $# -ne 2 ]
then
echo "输入的参数个数不对,请重新输入!!"
else
break
fi
let sum=$1+$2
echo "两数之和为:$sum"