1
2
3
|
(( a > b )) || (( a < c ))
[[ $a > $b ]] || [[ $a < $c ]]
[ $a -gt $b -o $a -lt $c ]
|
1
2
3
4
|
if
[
"$(whoami)"
!=
'root'
]; then
echo
"You have no permission to run $0 as non-root user."
exit
1
;
fi
|
1
2
3
4
|
doiido=
"hero"
if
[[
"$doiido"
== h* ]];then
echo
"hello,hero"
fi
|
1
2
3
4
5
6
7
8
9
10
11
|
#!/bin/sh
SYSTEM=`uname -s`
if
[ $SYSTEM =
"Linux"
] ; then
echo
"Linux"
elif [ $SYSTEM =
"FreeBSD"
] ; then
echo
"FreeBSD"
elif [ $SYSTEM =
"Solaris"
] ; then
echo
"Solaris"
else
echo
"What?"
fi
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#!/bin/bash
read -p
"please input a score:"
score
echo -e
"your score [$score] is judging by sys now"
if
[
"$score"
-ge
"0"
]&&[
"$score"
-lt
"60"
];then
echo
"sorry,you are lost!"
elif [
"$score"
-ge
"60"
]&&[
"$score"
-lt
"85"
];then
echo
"just soso!"
elif [
"$score"
-le
"100"
]&&[
"$score"
-ge
"85"
];then
echo
"good job!"
else
echo
"input score is wrong , the range is [0-100]!"
fi
|
1
2
3
4
5
6
7
8
9
10
|
#!/bin/sh
today=`date -d yesterday +%y%m%d`
file=
"apache_$today.tar.gz"
cd /home/chenshuo/shell
if
[ -f
"$file"
];then
echo
"OK"
else
echo
"error $file"
>error.log
mail -s
"fail backup from test"
loveyasxn924
@126
.com fi
|
1
2
3
4
5
6
|
#!/bin/bash
WEEKOFFSET=$[ $(date +
"%V"
) %
2
]
if
[ $WEEKOFFSET -eq
"0"
]; then
echo
"Sunday evening, put out the garbage cans."
| mail -s
"Garbage cans out"
your
@your_domain
.org
fi
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#! /bin/sh
dir_d=/media/disk_d
dir_e=/media/disk_e
dir_f=/media/disk_f
a=`ls $dir_d | wc -l`
b=`ls $dir_e | wc -l`
c=`ls $dir_f | wc -l`
echo
"checking disk_d..."
if
[ $a -eq
0
]; then
echo
"disk_d is not exsit,now creating..."
sudo mount -t ntfs /dev/disk/by-label/software /media/disk_d
else
echo
"disk_d exits"
fi
echo
"checking disk_e..."
if
[ $b -eq
0
]; then
echo
"disk_e is not exsit,now creating..."
sudo mount -t ntfs /dev/disk/by-label/elitor /media/disk_e
else
echo
"disk_e exits"
fi
echo
"checking disk_f..."
if
[ $c -eq
0
]; then
echo
"disk_f is not exsit,now creating..."
sudo mount -t ntfs /dev/disk/by-label/work /media/disk_f
else
echo
"disk_f exits"
fi
|