fork download
  1. #!/usr/bin/env bash
  2.  
  3. # set argument list, just as if the script were called with these arguments
  4. set -- -d /root/ -n "dhoni" -n "kohli"
  5.  
  6. # Initialize your array to start out empty
  7. empnames=( )
  8.  
  9. while getopts "d:n:" arg; do
  10. case "$arg" in
  11. d) path="$OPTARG" ;;
  12. n) empnames+=( "$OPTARG" ) ;;
  13. esac
  14. done
  15.  
  16. for arg in "${empnames[@]}"; do
  17. echo "$arg"
  18. done
  19.  
Success #stdin #stdout 0s 4364KB
stdin
Standard input is empty
stdout
dhoni
kohli