Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # A pretend Python dictionary with bash 3
- ARRAY=( "cow:moo"
- "dinosaur:roar"
- "bird:chirp"
- "bash:rock" )
- for animal in "${ARRAY[@]}" ; do
- KEY=${animal%%:*}
- VALUE=${animal#*:}
- printf "%s likes to %s.\n" "$KEY" "$VALUE"
- done
- echo -e "${ARRAY[1]%%:*} is an extinct animal which likes to ${ARRAY[1]#*:}\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement