builtin

Bash readarray builtin

Synonym for mapfile; reads records into an indexed array, default MAPFILE if no array is named. Bash 4.0+.

Formal Syntax & Structure

bash syntaxbash
readarray [-t] [-n count] [array]

Return Value

exit status

Synonym for mapfile; reads records into an indexed array, default MAPFILE if no array is named. Bash 4.0+.

Working Example

Example Snippetbash
printf '%s\n' one two > input.txtreadarray -t -n 1 lines < input.txtprintf '%s\n' "${lines[0]}"
Bash Reference