Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cd submissionAll/
- #ls -l
- #removing previous version of Absentee list.
- rm -f absenteeList.txt
- rm -f tempAbsenteeList.txt
- rm -f marks.txt
- rm -f Output/
- rm -f Temp/
- mkdir Output/
- mkdir Output/Extra
- mkdir Temp/
- #Getting all the rolls from the CSV files in absentee.txt
- sort -t',' ../CSE_322.csv | grep -o "[0-9]\{7\}"
- #getting all the file names in submissionAll/ folder. In this process, we can get the file name even if they has whitespace in them.
- ############## This part will work like a loop ###############
- find . -name "*.zip" |while read fname; do
- studentNameFromZipFile=`echo $(cut -d'_' -f1 <<< $fname | cut -d'/' -f2)`
- #${variable%pattern} is like $variable, minus shortest matching pattern from the back-end;
- #${variable##pattern} is like $variable, minus the longest matching pattern from front-end.
- delim="assignsubmission_file_"
- fileNameFromZip=${fname##*$delim}
- fileNameFromZip=${fileNameFromZip%.*}
- temRollNoFromZip=`$fileNameFromZip | grep -o "[0-9]\{7\}"`
- if [[ $temRollNoFromZip =~ ^.*[0-9]{7}.*$ ]]; then
- grep -vwE "$temRollNoFromZip" tempAbsenteeList.txt > absenteeList.txt
- cat absenteeList.txt > tempAbsenteeList.txt
- fi
- done
- #code absenteeList.txt
- find . -name "*.zip" |while read fname; do
- studentNameFromZipFile=`echo $(cut -d'_' -f1 <<< $fname | cut -d'/' -f2)`
- echo $fname
- delim="assignsubmission_file_"
- fileNameFromZip=${fname##*$delim}
- fileNameFromZip=${fileNameFromZip%.*}
- unzip -o "$fname" -d Temp/
- cd Temp/
- noOfSubDirectory=`ls | wc -l`
- if [ $noOfSubDirectory == 1 ]; then
- finalFolderName=`ls`
- if [[ $finalFolderName =~ ^[0-9]{7}$ ]]; then
- echo "$finalFolderName ---> 10" >> marks.txt
- mv "$finalFolderName" Output/
- elif [[ $finalFolderName =~ ^.*[0-9]{7}.*$ ]]; then
- tem=$finalFolderName
- #finalFolderName=`echo $(cut -d'_' -f1 <<< $finalFolderName)`
- finalFolderName=`echo "$finalFolderName" | grep -o "[0-9]\{7\}"`
- mv -T "$tem" "$finalFolderName"
- echo "$finalFolderName ---> 5" >> marks.txt
- mv "$finalFolderName" Output/
- else
- rollFromZip=`echo "$fileNameFromZip" | grep -o "[0-9]\{7\}"`
- if [[ $rollFromZip =~ "" ]]; then
- rollFromCSVFile=`cat CSE_322.csv | grep -iF "$studentNameFromZipFile" | grep -o "[0-9]\{7\}"`
- numberOfInstance=`cat CSE_322.csv | grep -ciF "Das"`
- if [ $numberOfInstance == 1 ]; then
- echo "$rollFromCSVFile ---> 0" >> marks.txt
- mv -T "$finalFolderName" "$rollFromCSVFile"
- mv "$rollFromCSVFile" Output/
- grep -vwE "$rollFromCSVFile" tempAbsenteeList.txt > absenteeList.txt
- cat absenteeList.txt > tempAbsenteeList.txt
- elif [ $numberOfInstance == 2 ]; then
- firstRoll=`echo -e "$rollFromCSVFile" | cut -d$'\n' -f1`
- secondRoll=`echo -e "$rollFromCSVFile" | cut -d$'\n' -f2`
- isStd1InAbsenteeListOrNot=`cat absenteeList.txt | grep -c "$firstRoll"`
- isStd2InAbsenteeListOrNot=`cat absenteeList.txt | grep -c "$secondRoll"`
- else
- fi
- else
- echo "$rollFromZip ---> 0" >> marks.txt
- mv -T "$finalFolderName" "$rollFromZip"
- mv "$rollFromZip" Output/
- fi
- fi
- else
- fi
- cd ..
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement