mapfile

From RaySoft

Read lines from the standard input into an indexed array variable.[1]

Documentation

Syntax

mapfile [PARAMETER ...] [ARRAY]

Parameters

-d DELIMITER
Use DELIMITER to terminate lines, instead of newline.
-n NUMBER
Copy at most NUMBER lines. If NUMBER is 0, all lines are copied.
-t
Remove a trailing DELIMITER from each line read (default newline).
-s NUMBER
Discard the first NUMBER lines read.

Examples

Find all variables with the name pattern machine_ & store them to the array machines
mapfile -t 'machines' < <(compgen -v 'machine_')

References

  1. bash -c 'help mapfile'