mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-02-16 01:48:57 +00:00
Update cheatsheets
This commit is contained in:
25
tldr/readarray
Normal file
25
tldr/readarray
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
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 {{array_name}} < {{path/to/file.txt}}`
|
||||
|
||||
- Remove trailing deliminators (newline by default):
|
||||
|
||||
`readarray -t {{array_name}} < {{path/to/file.txt}}`
|
||||
|
||||
- Copy at most the specified number of lines:
|
||||
|
||||
`readarray -n {{N}} {{array_name}} < {{path/to/file.txt}}`
|
||||
Reference in New Issue
Block a user