From b00d10698594c470030ae7907d6e72c6b7164e53 Mon Sep 17 00:00:00 2001 From: Kjetil Torgrim Homme Date: Tue, 1 Jul 2025 00:25:49 +0200 Subject: [PATCH] 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 --- bash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash.md b/bash.md index 745444ee..493d68b7 100644 --- a/bash.md +++ b/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