Decoding parameters in Bash script (1 space delimited)

This is a small script that takes a bash command and decodes the parameters in non sequential order except definers.

#!/bin/bash

if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then
  echo "Usage: $0 " >&2
  exit 1
fi




while [[ $# > 1 ]]
do
  key=”$1″
  echo $key
  shift
  case $key in
   -c|–color|color)
     COLOR=$1
     shift
     ;;
   -s|–section|section)
     SECTION=”yes”
     ;;
    *)

;;
esac
done

nJoy 😉

Leave a Reply

Your email address will not be published. Required fields are marked *