-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample17.sh
60 lines (46 loc) · 1.04 KB
/
example17.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
#!/usr/bin/bash
# Everythin in linux is a file.
# Types of files list here:
# Reqular file(text, picture): -
# Directory: d
# Symbolic link: I
# Named pipe: p
# Socket: s
# Block device: b
# Character device: c
FILE=/dev/log
FILE1=test.sh
FILE2=test2.sh
# Check if exists
[[ -e $FILE ]]
echo "[[ -e FILE ]]: $?"
# Check if readable
[[ -r $FILE ]]
echo "[[ -r FILE ]]: $?"
# Check if symlink
[[ -h $FILE ]]
echo "[[ -h FILE ]]: $?"
# Check if Directory
[[ -d $FILE ]]
echo "[[ -d FILE ]]: $?"
# Check if Writable
[[ -w $FILE ]]
echo "[[ -w FILE ]]: $?"
# Size is > 0 bytes
[[ -s $FILE ]]
echo "[[ -s FILE ]]: $?"
# Check if File
[[ -f $FILE ]]
echo "[[ -f FILE ]]: $?"
# Check if Executable
[[ -x $FILE ]]
echo "[[ -x FILE ]]: $?"
# Check if 1 is more recent than 2
[[ $FILE1 -nt $FILE2 ]]
echo "[[ FILE1 -nt FILE2 ]]: $?"
# Check if 2 is more recent than 1
[[ $FILE1 -ot $FILE2 ]]
echo "[[ FILE1 -ot FILE2 ]]: $?"
# Check if Same files
[[ $FILE1 -ef $FILE2 ]]
echo "[[ FILE1 -ef FILE2]]: $?"