summaryrefslogtreecommitdiff
path: root/auto.sh
diff options
context:
space:
mode:
authorpsachin2013-07-31 12:20:13 +0530
committerpsachin2013-07-31 12:20:13 +0530
commit9643c51f416d32851fce6b36a9a269b02d57f21e (patch)
tree8f3254aa261fdd1a0c5e213d3876dba93cdbcf7a /auto.sh
parentb843fb855e7d15c2af7d5553ab0a3187680d6f56 (diff)
downloadtbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.tar.gz
tbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.tar.bz2
tbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.zip
Subject: sorting of file-names w.r.t chapter number
Description: - sorting - added usage in ReadMe.md
Diffstat (limited to 'auto.sh')
-rwxr-xr-xauto.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/auto.sh b/auto.sh
index be67efc..6e01b6a 100755
--- a/auto.sh
+++ b/auto.sh
@@ -52,7 +52,25 @@ function scan_sce_for_errors() {
# make a list of all .sce file(with complete path). Exclude
# scanning 'DEPENDENCIES' DIR
- SCE_FILE_LIST=$(find ${ZIPFILE} -type f -iname "*.sce" ! -path "*/DEPENDENCIES*")
+
+ # That awk command says the field separator FS is set to /; this
+ # affects the way it reads fields. The output field separator OFS
+ # is set to "."; this affects the way it prints records. This is
+ # intentionally done so that 'cut' will take "." as a field
+ # Seperator during final sort operation. The next statement says
+ # print the last column (NF is the number of fields in the record,
+ # so it also happens to be the index of the last field) as well as
+ # the whole record ($0 is the whole record); it will print them
+ # with the OFS between them. Then the list is sorted, treating _
+ # as the field separator - since we have the filename first in the
+ # record, it will sort by that. Then the cut prints only fields 3
+ # through the end, again treating "." as the field separator.
+
+ SCE_FILE_LIST=$(find ${ZIPFILE} -type f -iname "*.sce" ! \
+ -path "*/DEPENDENCIES*" | \
+ awk -vFS=/ -vOFS="." '{print $NF,$0}' | \
+ sort -n -t _ -k1 -k2 | cut -d"." -f3-)
+
SCE_FILE_COUNT=$(echo "${SCE_FILE_LIST}" | wc -l)
echo -e "Total number of .sce files(without counting DEPENDENCIES directory): ${SCE_FILE_COUNT}\n" >> ./output_${ZIPFILE}.log