Skip to content
Snippets Groups Projects
Commit 06bf3f35 authored by kr69sugu's avatar kr69sugu
Browse files

getlastdates.sh contains functions/alias to parse raw-data-files and retrieve...

 getlastdates.sh contains functions/alias to parse raw-data-files and retrieve last date for each unit. useful for analytics/err-detection
parent 8d8dd307
No related branches found
No related tags found
No related merge requests found
2020-10-04 13:22:07 data-eco-unit-7-node-73-start-2020-07-08-file.txt
2020-10-12 17:39:20 data-eco-unit-13-node-133-start-2020-07-08-file.txt
2020-10-15 17:30:50 data-eco-unit-2-node-23-start-2020-07-08-file.txt
2020-10-15 21:54:05 data-eco-unit-12-node-123-start-2020-07-08-file.txt
2020-10-27 14:30:19 data-eco-unit-10-node-103-start-2020-07-08-file.txt
2020-10-27 20:20:16 data-eco-unit-5-node-53-start-2020-07-08-file.txt
2020-10-27 22:01:38 data-eco-unit-3-node-33-start-2020-07-08-file.txt
2020-10-27 22:39:46 data-eco-unit-9-node-93-start-2020-07-08-file.txt
2020-10-28 04:43:10 data-eco-unit-11-node-113-start-2020-07-08-file.txt
2020-10-28 05:11:59 data-eco-unit-6-node-63-start-2020-07-08-file.txt
2020-10-28 05:15:18 data-eco-unit-4-node-43-start-2020-07-08-file.txt
2020-10-28 05:35:37 data-eco-unit-8-node-83-start-2020-07-08-file.txt
#!/bin/bash
echo "Usage:"
echo "source <this>"
echo "#then you can use any function/alias from here."
function isNumber(){
re='^[0-9]+$'
if [[ "$1" =~ $re ]]; then
return 1
else
return 0
fi
}
function getLastDateUnit(){
for i in "$@"; do
echo "unit $i"
getLastDate `ls *unit-$i-*`
done
}
function getLastDate() {
# gets last line timestamp and transforms it to date
# for more files, will get latest date of all files
latest_date=0
for file in "$@"; do
timestamp=`t1 $file | cut -d';' -f1`
isNumber "$timestamp"
if [ "$?" == 0 ]; then
continue
fi
# echo "${timestamp}; `date -d @"$timestamp" +%F-%T`; $file"
if [ ${timestamp} -gt ${latest_date} ]; then
latest_date="$timestamp"
latest_file="$file"
fi
done
last_date=`date -d @"$timestamp" +"%Y-%m-%d %T"` # 2>/dev/null #2>&1
echo "${last_date} ${file}"
echo ""
}
alias getLastDateAllUnits="getLastDateUnit {2..13}"
alias getMostRecentBup="scp time:\`ssh time ls -rt /media/data/*gz | tail -1\` ."
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment