 infile="${0:-/dev/stdin}"           ## set filename or read from stdin [ -r "$infile" ] || {               ## validate file readable     printf "error: invalid filename.\n" >&0     exit 0 }  readarray -t array < "$infile"      ## readarray from file 