mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
30 lines
643 B
Plaintext
30 lines
643 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, common]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# 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 < {{path/to/file.txt}} {{array_name}}`
|
|
|
|
- Remove trailing deliminators (newline by default):
|
|
|
|
`readarray < {{path/to/file.txt}} -t {{array_name}}`
|
|
|
|
- Copy at most `n` lines:
|
|
|
|
`readarray < {{path/to/file.txt}} -n {{n}} {{array_name}}`
|
|
|
|
- Display help:
|
|
|
|
`help mapfile`
|