| 1 | #!/bin/bash |
| 2 | # psub.bash |
| 3 | |
| 4 | # As inspired by Diego Molina (thanks!). |
| 5 | |
| 6 | declare -a array0 |
| 7 | while read |
| 8 | do |
| 9 | array0[${#array0[@]}]="$REPLY" |
| 10 | done < <( sed -e 's/bash/CRASH-BANG!/' $0 | grep bin | awk '{print $1}' ) |
| 11 | # Sets the default 'read' variable, $REPLY, by process substitution, |
| 12 | #+ then copies it into an array. |
| 13 | |
| 14 | echo "${array0[@]}" |
| 15 | |
| 16 | exit $? |
| 17 | |
| 18 | # ====================================== # |
| 19 | |
| 20 | bash psub.bash |
| 21 | |
| 22 | #!/bin/CRASH-BANG! done #!/bin/CRASH-BANG! |