林博仁 Buo-ren Lin says to Ubuntu 台灣社群
Bash 讀檔排除空行跟井號註解行: # Loading lines from a file or stream - BashFAQ/005 - Greg's Wiki # https://mywiki.wooledge.org/BashFAQ/005#Loading_lines_from_a_file_or_stream data=() mapfile -t lines < "${file}" for line in "${lines[@]}"; do empty_line_regex='^[[:space:]]*$' comment_line_regex='^[[:space:]]*#.*$' if [[ ${line} =~ ${empty_line_regex} ]] \ || [[ ${line} =~ ${comment_line_regex} ]]; then continue; fi data+=("${line}") done