-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocator.sh
31 lines (27 loc) · 1020 Bytes
/
locator.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
#!/bin/bash
# Fix the the bug related to wrong locating files
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "The script takes files from Students/ folder and places them to Tasks/ folder according to task numbers"
echo " Usage:"
echo -e "\t./locator.sh [option] (task number to start) (task number to finish)"
echo " Example:"
echo -e "\t./locator.sh -h \tIt will show the help page"
echo -e "\t./locator.sh 1 20\tIt will locate files from task 1 to task 20 in Tasks/ folder "
echo -e "\t./locator.sh 11 11\tIt will locate files only from task 11 into Tasks/ folder "
exit 0
fi
if [[ $# -lt 2 || $# -gt 2 ]]; then
echo "Wrong number of arguments"
exit 1
fi
for num in $(seq "$2" -1 "$1"); do
for student in Students/*; do
for task in $student/*; do
if [[ "$task" =~ "ask"$num"_" && "$task" != *"checked"* ]]; then
mv $task Tasks/Task_$num/Students
fi
done
done
echo "Task_$num"
done
echo "Done"