diff --git a/getDates.sh b/getDates.sh index 5642fee59a5a1d98b7b31f5b9d1e95a64e234fb8..e769dbbce1ecd5697b9fc716fda0ef46f190ac95 100755 --- a/getDates.sh +++ b/getDates.sh @@ -1,12 +1,13 @@ #!/bin/bash # # # # -# Determine time of last and first Trackevent in file/unit +# Determine start and end of Trackevents in files/units +# >> summarizes for all files for a unit and for all units # # Why? Because timestamp is not human-readable and one unit can have multiple files. -# ## -function isNumber(){ +function isNumber() { + re='^[0-9]+$' if [[ "$1" =~ $re ]]; then return 1 @@ -15,16 +16,30 @@ function isNumber(){ fi } +function getHeaderSize { + + HEADER_SIZE=0 + while read -r line; do + if [ ${line::1} != '#' ]; then + break + fi + ((HEADER_SIZE++)) + done < "$1" +} + function getDates() { - # gets second/last line timestamp and transform it to date + # gets first line after header and last line timestamp and transform it to date # for more files, will get latest/earliest date of all files date1=`date +%s` date2=0 for file in "$@"; do - timestamp1=`head -2 "$file" | tail -1 | cut -d';' -f1` + # echo "process file $file" + getHeaderSize "$file" + + timestamp1=`head -$((HEADER_SIZE+1)) "$file" | tail -1 | cut -d';' -f1` timestamp2=`tail -1 "$file" | cut -d';' -f1` - + isNumber "$timestamp1" if [ "$?" != 0 ]; then if [ ${timestamp1} -lt ${date1} ]; then @@ -32,7 +47,7 @@ function getDates() { file1="$file" fi else - echo "nonum" + echo "nonum" >> /dev/stderr fi isNumber "$timestamp2" @@ -42,7 +57,7 @@ function getDates() { file2="$file" fi else - echo "nonum" + echo "nonum" >> /dev/stderr fi done @@ -63,6 +78,7 @@ function getDates() { } function getDatesUnit(){ + for i in "$@"; do echo "unit $i" files=`ls "$dir"/*unit-$i-* 2> /dev/null` @@ -76,13 +92,12 @@ function getDatesUnit(){ } function getDatesAll() { - + earliest=`date +%s` latest=0 getDatesUnit {1..13} - earliest=`date -d @"$earliest" +"%Y-%m-%d %T"` latest=`date -d @"$latest" +"%Y-%m-%d %T"` echo "unit all" @@ -90,6 +105,8 @@ function getDatesAll() { echo "${latest} ${latestFile}" } +#################################### + if [ -z $1 ];then dir="." else @@ -100,4 +117,4 @@ else fi fi -getDatesAll # > "${dir}/../02-inspect/dates" +getDatesAll diff --git a/unknown-tags.sh b/unknown-tags.sh index c1fb02b2dde7c34a2fbf3a2f8649627b1a43503f..f8da8b58508bd4ce961d00add06fc0c6dc0b22f8 100755 --- a/unknown-tags.sh +++ b/unknown-tags.sh @@ -1,5 +1,5 @@ #!/bin/bash -# scriptdir=`dirname $0` + this=`basename $0` out1="tags_unknown" out2="tags_info"