builtin
Bash mapfile builtin
Collects records into an indexed array. -t removes the delimiter; -n limits record count (0 means unlimited). Bash 4.0+; not POSIX sh.
Formal Syntax & Structure
bash syntaxbash
mapfile [-t] [-n count] [array]Return Value
exit status
Collects records into an indexed array. -t removes the delimiter; -n limits record count (0 means unlimited). Bash 4.0+; not POSIX sh.
Working Example
Example Snippetbash
printf '%s\n' one 'two words' > input.txtmapfile -t lines < input.txtprintf '[%s]\n' "${lines[@]}"