mapfile -t lines < file.txt

Category: Shell & Bash

mapfile -t lines < file.txt

Read file lines into an array variable

Reads every line of a file into an array, with each line becoming one array element. -t strips trailing newlines.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.