Skip to main content
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

Your question is unclear about what maps to what, but if your bash version is >= 4, you can use an associative array:

declare -A mapping=(
    [2019-01]="some-id"
    [2019-02]="some-other-id"
)

mon=$(process that retrieves the YYYY-MM)
campaign_id=${mapping[$mon]}
if [[ -z $campaign_id ]]; then
    echo "no mapping for month $mon"
else
    go fetch with "$campaign_id"
fi
Post Made Community Wiki by glenn jackman