2021-01-28 13:49:56 +01:00
|
|
|
#!/bin/bash
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
printf "start at reading no. L-"
|
|
|
|
read -r start_no
|
|
|
|
else
|
2021-01-28 15:39:34 +01:00
|
|
|
last_line="$(tail -n1 readings_index)"
|
|
|
|
echo "$last_line"
|
|
|
|
start_no="$( echo "$last_line" | cut -f3)"
|
2021-01-28 13:49:56 +01:00
|
|
|
fi
|
2021-01-28 15:39:34 +01:00
|
|
|
for ((n=start_no;n<=4000;n++)); do
|
2021-01-27 22:24:33 +01:00
|
|
|
printf "index of reading no. L-%s:" "$n"
|
2021-01-27 19:51:07 +01:00
|
|
|
read -r index
|
2021-01-28 13:49:56 +01:00
|
|
|
if [ "$index" = "" ]; then
|
|
|
|
continue
|
2021-01-28 15:39:34 +01:00
|
|
|
elif [ "$index" = "d" ]; then
|
|
|
|
echo "deleting last line"
|
|
|
|
grep -v "$(tail -n1 readings_index)" readings_index > tmp$$
|
|
|
|
mv tmp$$ readings_index
|
2021-01-28 16:21:32 +01:00
|
|
|
tail -n1 readings_index
|
2021-01-28 15:39:34 +01:00
|
|
|
n="$(( n - 2 ))";
|
2021-01-28 13:49:56 +01:00
|
|
|
elif [ "$index" -gt 0 ]; then
|
2021-01-27 22:24:33 +01:00
|
|
|
line="$(grep -P "^$index\t" lesungen)"
|
|
|
|
printf '%s\t%s\n' "$line" "$n" | tee -ai readings_index
|
2021-01-28 13:49:56 +01:00
|
|
|
elif [ "$index" -eq 0 ]; then
|
|
|
|
n="$(( n - 2 ))";
|
2021-01-27 22:24:33 +01:00
|
|
|
fi
|
2021-01-27 19:51:07 +01:00
|
|
|
done
|