bash array hints

source: http://www.linuxjournal.com/content/bash-arrays If you’re used to a “standard” *NIX shell you may not be familiar with bash’s array feature. Although not as powerful as similar constructs in the P languages (Perl, Python, and PHP) and others, they are often quite useful. Bash arrays have numbered indexes only, but they are sparse, ie you don’t have […]

bash – read command results into an array

read -a ARRAY <<< $(df -h /data | grep -w /data) OR read -d DELIMITER -a ARRAY <<< $(df -h /data | grep -w /data) THIS DOES NOT WORK FOR ME OR OIFS=$IFS;IFS=$’\|’;read -a ARRAY <<< “$STRING2PROCESS”;IFS=$OIFS # for delimiter ‘|’ OR BETTER (!) ARRAY=($(df -h /data | grep -w /data)) HINT —> OIFS=$IFS;IFS=$’\|’;read -a […]