-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateDefaulter.sh
executable file
·51 lines (44 loc) · 1.14 KB
/
updateDefaulter.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
#!/bin/bash
# user=$(whoami)
user="Agate"
read -p "Enter last date for payment (YYYY:MM:DD): " lastDate
find /home/$user -type f -name fees.txt > /home/allFiles.txt
rm /home/$user/feeDefaulters.txt
while read line
do
while read data
do
read -a feeData <<< "$data"
cond=false
paidOnTime=false
if [ ${feeData[0]} = "Trans" ]
then
if [ ${feeData[0]} \< lastDate ]
then
paidOnTime=true
cond=true
else
cond=true
fi
fi
done < $line
if [ $cond = false ] || [ $paidOnTime = false ]
then
IFS="\/"
read -ra address <<< "$line"
IFS=" "
count=0
reqDetails=()
room=${address[3]}
name=${address[4]}
while read details
do
read -a detail <<< "$details"
reqDetails+=(${detail[1]})
done < "/home/$user/$room/$name/userDetails.txt"
rollno=${reqDetails[1]}
echo "$name $rollno" >> /home/$user/feeDefaulters.txt
fi
done < /home/allFiles.txt
rm /home/allFiles.txt
echo "Updated feeDefaulters.txt!"