From e5f6e159f2e97232a039f16e40003f8ce8216cd8 Mon Sep 17 00:00:00 2001 From: Patrick Winters <19wintersp@gmail.com> Date: Wed, 11 Sep 2024 20:24:48 +0100 Subject: [PATCH] feat: multiple SCTs for auto SCT2 script --- workflows/airac/update-smr-labels.sh | 33 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/workflows/airac/update-smr-labels.sh b/workflows/airac/update-smr-labels.sh index a33668f6b..9585395e4 100644 --- a/workflows/airac/update-smr-labels.sh +++ b/workflows/airac/update-smr-labels.sh @@ -2,32 +2,37 @@ set -eux -SCT=UK/Data/Sector/*.sct - -if [ ! -e $SCT ] ; then - exit 1 -fi - TMP1=$(mktemp) TMP2=$(mktemp) +TMPD=$(mktemp -d) -OFS=$(grep -nF "[LABELS]" $SCT | cut -d: -f1) -tail -n +$OFS $SCT | tail -n +2 > $TMP1 +for SCT in UK/Data/Sector/*.sct ; do + BAS=$(basename "$SCT") -LEN=$(grep -nE "^\[.+\]$" $TMP1 | cut -d: -f1) -head -n $LEN $TMP1 | grep -oE '^".+"\s' | cut -d\" -f2 | LC_ALL=C sort -fu > $TMP2 + OFS=$(grep -nF "[LABELS]" "$SCT" | cut -d: -f1) + tail -n +$OFS "$SCT" | tail -n +2 > $TMP1 -LEN=$(wc -l < $TMP2) -yes "Free Text:SCT2" | head -n $LEN | paste -d\\\\ - $TMP2 > $TMP1 -yes "freetext" | head -n $LEN | paste -d: $TMP1 - > $TMP2 + LEN=$(grep -nE "^\[.+\]$" $TMP1 | cut -d: -f1) + head -n $LEN $TMP1 | grep -oE '^".+"\s' | cut -d\" -f2 | LC_ALL=C sort -fu > $TMP2 + + LEN=$(wc -l < $TMP2) + yes "Free Text:SCT2" | head -n $LEN | paste -d\\\\ - $TMP2 > $TMP1 + yes "freetext" | head -n $LEN | paste -d: $TMP1 - > "$TMPD/$BAS" +done grep -lrF "SMR radar display" --include=*.asr | while read -r ASR ; do + ASD=${ASR#*/} + PRF=$(grep -lrF "${ASD//\//\\}" --include=*.prf | head -n1) + SCT=$(grep -E "Settings\s+sector" "$PRF" | cut -f3) + SCT=${SCT##*\\} + grep -vF "Free Text:SCT2\\" "$ASR" > $TMP1 OFS=$(grep -m1 -nF "Free Text:SCT2\\" "$ASR" | cut -d: -f1) head -n $OFS $TMP1 | head -n -1 > "$ASR" - cat $TMP2 >> "$ASR" + cat "$TMPD/$SCT" >> "$ASR" tail -n +$OFS $TMP1 >> "$ASR" done rm $TMP1 $TMP2 +rm -r $TMPD