1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 10:22:10 +02:00
tldr/pages/common/readarray.md
Lena 6fd816e36e
pages/*: use lowercase n for integer placeholders (#16033)
Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2025-03-27 21:23:12 +05:30

24 lines
550 B
Markdown

# readarray
> Read lines from `stdin` into an array.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-readarray>.
- Interactively input lines into an array:
`readarray {{array_name}}`
- Read lines from a file and insert them in an array:
`readarray {{array_name}} < {{path/to/file.txt}}`
- Remove trailing deliminators (newline by default):
`readarray -t {{array_name}} < {{path/to/file.txt}}`
- Copy at most `n` lines:
`readarray -n {{n}} {{array_name}} < {{path/to/file.txt}}`
- Display help:
`help mapfile`