-
Notifications
You must be signed in to change notification settings - Fork 0
/
weekdays.sh
73 lines (71 loc) · 1.11 KB
/
weekdays.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 " Today is "
day=$(date '+%a')
echo "$day"
case $day in
'Mon') echo "create 2 files at1 and at2"
touch at1 at2
;;
'Tue') echo "add contents to files at1 and at2"
if [ -f at1 ]
then
echo "write the content to file at1"
cont1=$@
echo "$cont1" >> at1
else
echo "at1 file doesn't exist"
fi
if [ -f at2 ]
then
echo "write the content to file at2"
echo "$@" >> at2
else
echo "at2 doesn't exist"
fi
mkdir -p temp
;;
'Wed') echo "moving the files at1 and at2 to temp folder"
if [ -f at1 ]
then
mv at1 temp/
else
echo "at1 file doesn't exist"
fi
if [ -f at2 ]
then
mv at2 temp2/
else
echo "at2 file doesn't exist"
fi
;;
'Thu') echo " creating backup files"
if [ -f at1 ]
then
cp temp/at1 backup1
else
echo "at1 file doesn't exist"
fi
if [ -f at2 ]
then
cp temp/at2 backup2
else
echo "at2 file doesn't exist"
fi
;;
'Fri') echo "removing files at1 and at2 "
if [ -f at1 ]
then
rm temp/at1
else
echo "at1 file doesn't exist"
fi
if [ -f at2 ]
then
rm temp/at2
else
echo "at2 file doesn't exist"
fi
;;
'Sat'|'Sun') echo "Today is holiday"
;;
esac