Advertisement
cd62131

Array Sample

Dec 3rd, 2013
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash -e
  2. typeset -a array
  3. cat <<CAT | while read -a array
  4. a b c d
  5. b c d a
  6. c d a b
  7. d a b c
  8. CAT
  9. do
  10.   echo ${array[@]} >> data
  11.   typeset -i i
  12.   for ((i = 0; i < ${#array[@]}; i++))
  13.   do
  14.     if echo ${array[$i]} | grep '^a' >& /dev/null
  15.     then
  16.       echo "${array[$i]} found"
  17.     else
  18.       echo 'not found'
  19.     fi
  20.   done
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement