-
Notifications
You must be signed in to change notification settings - Fork 3
/
switchdays.sh
72 lines (72 loc) · 1.26 KB
/
switchdays.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
#!/bin/bash
echo "enter the day"
read day
echo "$day"
case $day in
'mon') echo "create 2 files p1 and p2"
touch p1 p2
;;
'tue') echo "add contents to the file p1 and p2"
if [ -f p1 ]
then
echo "write the content to the file p1"
read part1
echo "$part1" >> p1
else
echo "p1 file doesn't exist"
fi
if [ -f p2 ]
then
echo "write the content to the file p2"
read part2
echo "$part2" >> p2
else
echo "p2 file doesn't exist"
fi
mkdir -p temp
;;
'wed') echo "moving files p1 and p2 tp to temp folder"
if [ -f p1 ]
then
mv p1 temp/
else
echo"p1 file doesn't exist"
fi
if [ -f p2 ]
then
mv p2 temp/
else
echo"p2 file dosen't exist"
fi
;;
'thu') echo "creating backup files"
if [ -f temp/p1 ]
then
cp temp/p1 backup1
else
echo "p1 file doesn't exist"
fi
if [ -f temp/p2 ]
then
cp temp/p2 backup2
else
echo "p2 file doesn't exist"
fi
;;
'fri') echo "deleting files p1 and p2"
if [ -f temp/p1 ]
then
rm temp/p1
else
echo "p1 file doesn't exist"
fi
if [ -f temp/p2 ]
then
rm temp/p2
else
echo "p2 file doesn't exist"
fi
;;
'sat'|'sun') echo "today is holiday"
;;
esac