jottings
#!/bin/env sh
[ -r /etc/hostname ] && source /etc/hostname
HOSTNAME=${hostname:-www.abc.com}
hostname $HOSTNAME
/etc/hostname
hostname=www.ibm.com
./filename.sh是生成子shell执行,设置当前bash的环境变量,必须使用 . 或source执行,才能生效
1 for p in /etc/profile.d/*.sh;do
2 if [ -r "$p" ];then
3 . $p
4 fi
5 done
: 类似于python中的pass,do nothing,return 0,即exit 0
1 if [ "$p" -eq 1 ];then
2 :
3 else
4 echo "$p not equal 1"
5 fi
echo $((2**4))
1 #!/bin/env sh
2
3 disks=$(fdisk -l /dev/[sh]d[a-z] | grep -o '^Disk /dev/[sh]d[a-z]' | wc --lines)
4
5 if [[ $disks -eq 1 ]];then
6 fdisk -l /dev/[sh]da
7 else
8 fdisk -l $(fdisk -l /dev/[sh]d[a-z] |grep -o '^Disk /dev/[sh]d[a-z]'|tail -1|cut -d' ' -f2)
9 fi