Skip to content

Instantly share code, notes, and snippets.

@leotm
Created March 29, 2017 11:27
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 leotm/87391bee805deca353b2b9109344c91f to your computer and use it in GitHub Desktop.
Save leotm/87391bee805deca353b2b9109344c91f to your computer and use it in GitHub Desktop.
A shell script that creates an associate array and generates prefixed php files that redirect to the matching URLs
# How to iterate over associate arrays in Bash
# To generate PHP redirection files with prefixes
declare -A array
array["uk"]="https://www.google.co.uk"
array["fi"]="https://www.google.fi"
array["es"]="https://www.google.es"
for i in "${!array[@]}"
do
echo "<?php header('Location: ${array[$i]}'); ?>" > prefix-$i.php
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment