Erinnermich/erinnermich-collect.sh

42 lines
826 B
Bash
Executable File

#! /usr/bin/env bash
#Prepare Flags and Variables
OF="md"
FF="future"
WF="open"
MF=false
TF="future"
ARGS=($@)
FILES=()
BASEPATH=$(dirname $(realpath $0))
. .env # FINDPATH
#Read command line input
for (( ARG=0; ARG<$#; ARG++ ))
do
VAL=${ARGS[$ARG]}
case $VAL in
"-m") MF=true;;
"-f") FF=${ARGS[$ARG+1]};;
"-w") WF=${ARGS[$ARG+1]};;
"-t") TF=${ARGS[$ARG+1]};;
"-a") TF="all"; WF="all"; FF="all";;
"-am") TF="all"; WF="all"; FF="all"; MF=true;;
esac
done
#find data
FILES=$(find $FINDPATH -iname ".erinnermich.csv")
#collect data into one file
echo "date,type,handle,done,comment" > .erinneralle.csv # Lösche Sammeldatei und lege Kopfzeile an
for FILE in $FILES
do
if [[ $(head -n 1 $FILE) =~ "date,type,handle,done,comment" ]]
then
echo $FILE
tail -n +2 $FILE >> $BASEPATH/.erinneralle.csv
fi
done