From 9643c51f416d32851fce6b36a9a269b02d57f21e Mon Sep 17 00:00:00 2001 From: psachin Date: Wed, 31 Jul 2013 12:20:13 +0530 Subject: Subject: sorting of file-names w.r.t chapter number Description: - sorting - added usage in ReadMe.md --- ReadMe.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- auto.sh | 20 +++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 549eb83..ecff640 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,4 +1,57 @@ # tbc-auto-checker ### Auto checker script for Scilab Textbook Companion. -### Please visit [http://scilab.in/Textbook_Companion_Project](http://scilab.in/Textbook_Companion_Project) for more info. +### Usage + +* Clone this repository + +```bash +git clone https://github.com/Scilab-India/tbc-auto-checker.git +``` + +* Change path to this directory + +```bash +cd tbc-auto-checker +``` + +* Place ZIP file(s) of book(s) in this directory and run the script + +```bash +bash auto.sh +``` + +### Output + +* The output log files and error log files will be generated +separately. + +#### text output + +* Text output will be stored in `output_.log` file. + +#### graph output + +* You have to set a variable `SCI_GRAPH_PATH` to a path where you want +all the graphs to be stored. + +* Graphs with text output will be stored in + `output_graph_.log` file + +#### errors + +* **for text based errors**: `error_.log` + +* **for graph based errors**: `error_graph_.log` + +#### Warning + +* All output are first stored in a variable and then written to + respective files. You may run out of memory sometimes. + +#### Site + +Please visit +[http://scilab.in/Textbook_Companion_Project](http://scilab.in/Textbook_Companion_Project) +for more info. + 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 -- cgit