Advertisement
zamotivator

Untitled

Nov 30th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # A pretend Python dictionary with bash 3
  4. ARRAY=( "cow:moo"
  5. "dinosaur:roar"
  6. "bird:chirp"
  7. "bash:rock" )
  8.  
  9. for animal in "${ARRAY[@]}" ; do
  10. KEY=${animal%%:*}
  11. VALUE=${animal#*:}
  12. printf "%s likes to %s.\n" "$KEY" "$VALUE"
  13. done
  14.  
  15. echo -e "${ARRAY[1]%%:*} is an extinct animal which likes to ${ARRAY[1]#*:}\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement