-
Notifications
You must be signed in to change notification settings - Fork 0
/
007_test.sh
executable file
·84 lines (68 loc) · 1.3 KB
/
007_test.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
echo "creating testfile.testfile"
touch testfile.testfile
echo "is file exists?"
if [ -e testfile.testfile ]
then echo "yes!"
else echo "no!"
fi
echo "is it a directory?"
if [ -d testfile.testfile ]
then echo Yes!
else echo No!
fi
echo "is it a regular file?"
if [ -f testfile.testfile ]
then echo "yes!"
else echo "no!"
fi
echo "is it readable?"
if [ -r testfile.testfile ]
then echo "yes!"
else echo "no!"
fi
echo "is it writable?"
if [ -w testfile.testfile ]
then echo "yes!"
else echo "no!"
fi
echo "is it executable?"
if [ -x testfile.testfile ]
then echo "yes!"
else echo "no!"
fi
echo "string test"
MY_STRING=""
echo "is it empty?"
if [ -z $MY_STRING ]
then echo "yes!"
else echo "no!"
fi
MY_STRING="Notemptyanymore!"
echo "is it not empty?"
if [ -n $MY_STRING ]
then echo "yes!"
else echo "no!"
fi
STRING_1="String1"
echo "does STRING_1 exists!"
if [ $STRING_1 ]
then echo "yes!"
else echo "no!"
fi
echo "does STRING_2 exists!"
if [ $STRING_2 ]
then echo "yes!"
else echo "no!"
fi
STRING_2="String2"
echo "are STRING_1 and STRING_2 equal?"
if [ $STRING_1 = $STRING_2 ]
then echo "yes!"
else echo "no!"
fi
echo "okay so it's not equal?"
if [ $STRING_1 != $STRING_2 ]
then echo "yes!"
else echo "no!"
fi