mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-10-16 07:28:25 +02:00
bash: adjust example to read from file into array (#2187)
* use `$()` rather than deprecated `` * illustrate shortcut for builtin read of file without `cat` * don't imply this reads lines, it will split into words by default perhaps the cheatsheet should have a section on IFS, but that's off-topic for this patch. Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
This commit is contained in:
parent
1ba47a8e7e
commit
b00d106985
2
bash.md
2
bash.md
@ -510,7 +510,7 @@ Fruits=( "${Fruits[@]/Ap*/}" ) # Remove by regex match
|
||||
unset Fruits[2] # Remove one item
|
||||
Fruits=("${Fruits[@]}") # Duplicate
|
||||
Fruits=("${Fruits[@]}" "${Veggies[@]}") # Concatenate
|
||||
lines=(`cat "logfile"`) # Read from file
|
||||
words=($(< datafile)) # From file (split by IFS)
|
||||
```
|
||||
|
||||
### Iteration
|
||||
|
Loading…
x
Reference in New Issue
Block a user