Advertisement
Guest User

Untitled

a guest
Nov 10th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. cd submissionAll/
  3. #ls -l
  4.  
  5. #removing previous version of Absentee list.
  6. rm -f absenteeList.txt
  7. rm -f tempAbsenteeList.txt
  8. rm -f marks.txt
  9.  
  10. rm -f Output/
  11. rm -f Temp/
  12.  
  13. mkdir Output/
  14. mkdir Output/Extra
  15. mkdir Temp/
  16.  
  17.  
  18.  
  19. #Getting all the rolls from the CSV files in absentee.txt
  20.  
  21. sort -t',' ../CSE_322.csv | grep -o "[0-9]\{7\}"
  22.  
  23.  
  24.  
  25. #getting all the file names in submissionAll/ folder. In this process, we can get the file name even if they has whitespace in them.
  26.  
  27. ############## This part will work like a loop ###############
  28.  
  29. find . -name "*.zip" |while read fname; do
  30.   studentNameFromZipFile=`echo $(cut -d'_' -f1 <<< $fname | cut -d'/' -f2)`
  31.  
  32.  
  33. #${variable%pattern} is like $variable, minus shortest matching pattern from the back-end;
  34. #${variable##pattern} is like $variable, minus the longest matching pattern from front-end.
  35.  
  36.   delim="assignsubmission_file_"
  37.   fileNameFromZip=${fname##*$delim}
  38.  
  39.   fileNameFromZip=${fileNameFromZip%.*}
  40.   temRollNoFromZip=`$fileNameFromZip | grep -o "[0-9]\{7\}"`
  41.  
  42.   if [[ $temRollNoFromZip =~ ^.*[0-9]{7}.*$ ]]; then
  43.         grep -vwE "$temRollNoFromZip" tempAbsenteeList.txt > absenteeList.txt
  44.  
  45.         cat absenteeList.txt > tempAbsenteeList.txt    
  46.   fi
  47.  
  48. done
  49.  
  50. #code absenteeList.txt
  51.  
  52. find . -name "*.zip" |while read fname; do
  53.   studentNameFromZipFile=`echo $(cut -d'_' -f1 <<< $fname | cut -d'/' -f2)`
  54.  
  55.   echo $fname
  56.  
  57.   delim="assignsubmission_file_"
  58.   fileNameFromZip=${fname##*$delim}
  59.  
  60.   fileNameFromZip=${fileNameFromZip%.*}
  61.  
  62.   unzip -o "$fname" -d Temp/
  63.   cd Temp/
  64.  
  65.   noOfSubDirectory=`ls | wc -l`
  66.  
  67.   if [ $noOfSubDirectory == 1 ]; then
  68.        finalFolderName=`ls`
  69.        if [[ $finalFolderName =~ ^[0-9]{7}$ ]]; then
  70.             echo "$finalFolderName --->  10" >> marks.txt
  71.             mv "$finalFolderName" Output/
  72.  
  73.        elif [[ $finalFolderName =~ ^.*[0-9]{7}.*$ ]]; then
  74.             tem=$finalFolderName
  75.  
  76.             #finalFolderName=`echo $(cut -d'_' -f1 <<< $finalFolderName)`
  77.  
  78.             finalFolderName=`echo "$finalFolderName" | grep -o "[0-9]\{7\}"`
  79.  
  80.             mv -T "$tem" "$finalFolderName"
  81.  
  82.             echo "$finalFolderName --->  5" >> marks.txt
  83.             mv "$finalFolderName" Output/
  84.  
  85.        else
  86.  
  87.             rollFromZip=`echo "$fileNameFromZip" | grep -o "[0-9]\{7\}"`
  88.  
  89.             if [[ $rollFromZip =~ "" ]]; then
  90.  
  91.                 rollFromCSVFile=`cat CSE_322.csv | grep -iF "$studentNameFromZipFile" | grep -o "[0-9]\{7\}"`
  92.  
  93.                 numberOfInstance=`cat CSE_322.csv | grep -ciF "Das"`
  94.  
  95.                 if [ $numberOfInstance == 1 ]; then
  96.                    
  97.                     echo "$rollFromCSVFile --->  0" >> marks.txt
  98.                     mv -T "$finalFolderName" "$rollFromCSVFile"
  99.                     mv "$rollFromCSVFile" Output/
  100.  
  101.  
  102.                     grep -vwE "$rollFromCSVFile" tempAbsenteeList.txt > absenteeList.txt
  103.                     cat absenteeList.txt > tempAbsenteeList.txt
  104.  
  105.                 elif [ $numberOfInstance == 2 ]; then
  106.  
  107.                     firstRoll=`echo -e "$rollFromCSVFile" | cut -d$'\n' -f1`
  108.  
  109.                     secondRoll=`echo -e "$rollFromCSVFile" | cut -d$'\n' -f2`
  110.  
  111.                     isStd1InAbsenteeListOrNot=`cat absenteeList.txt | grep -c "$firstRoll"`
  112.  
  113.                     isStd2InAbsenteeListOrNot=`cat absenteeList.txt | grep -c "$secondRoll"`
  114.  
  115.                    
  116.  
  117.                 else
  118.  
  119.                 fi
  120.  
  121.  
  122.  
  123.                
  124.  
  125.             else
  126.                 echo "$rollFromZip --->  0" >> marks.txt
  127.                 mv -T "$finalFolderName" "$rollFromZip"
  128.                 mv "$rollFromZip" Output/
  129.             fi
  130.  
  131.        fi
  132.  
  133.      
  134.   else
  135.  
  136.   fi
  137.  
  138.   cd ..
  139.  
  140. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement