Bash function to read the lines of a file into an array using the builtin, mapfile.

  • Reads the lines of the specified file into an array. The resulting array is in the dedicated variable, MAPFILE.
  • Skips "commented" lines or portions of lines.
  • Skips blank lines.
  • Trims leading & trailing spaces in every line.
aslamK Over 9 years ago