diff options
author | psachin | 2013-07-31 12:20:13 +0530 |
---|---|---|
committer | psachin | 2013-07-31 12:20:13 +0530 |
commit | 9643c51f416d32851fce6b36a9a269b02d57f21e (patch) | |
tree | 8f3254aa261fdd1a0c5e213d3876dba93cdbcf7a /auto.sh | |
parent | b843fb855e7d15c2af7d5553ab0a3187680d6f56 (diff) | |
download | tbc-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-x | auto.sh | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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 |