Skip to content

Instantly share code, notes, and snippets.

@w4tson
Created October 4, 2022 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w4tson/2109ab7ee2b3619db7acb7b7b5c86ea0 to your computer and use it in GitHub Desktop.
Save w4tson/2109ab7ee2b3619db7acb7b7b5c86ea0 to your computer and use it in GitHub Desktop.
A little test of bash hashmaps, dynamic arrays etc
dir_mappings() {
case $1 in
'ABC_DET') echo 'ABC_DET';;
'DDD_DET') echo 'DDD_DET';;
'ZZZ_DET') echo 'ZZZ_DET';;
'ZZZ_1') echo 'ZZZ_DET';;
'ZZZ_2') echo 'ZZZ_DET';;
'ZZZ_3') echo 'ZZZ_DET';;
*) echo 'nope';;
esac
}
batches=()
for folder in `find ./FILES/svc/* -type d`
do
dataset=`echo "$folder" | sed 's|.*/||'`
echo "processing $dataset"
for filepath in `find ./FILES -name "$dataset*.dmp"`
do
file=`sed 's|.*/||' <<< $filepath`
batch=`sed 's/\(.*\)_[0-9]\{2\}\.dmp/\1/' <<< $file`
batches+=($batch)
done
done
unique_batches=`echo "${batches[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '`
for b in $unique_batches
do
echo $b
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment