diff --git a/README.md b/README.md index 8654357..bca6048 100644 --- a/README.md +++ b/README.md @@ -878,9 +878,14 @@ file_data="$(<"file")" Alternative to the `cat` command. ```shell -# Bash <4 +# Bash <4 (discarding empty lines). IFS=$'\n' read -d "" -ra file_data < "file" +# Bash <4 (preserving empty lines). +while read -r line; do + file_data+=("$line") +done < "file" + # Bash 4+ mapfile -t file_data < "file" ``` diff --git a/manuscript/chapter4.txt b/manuscript/chapter4.txt index e7bb50a..902fec6 100644 --- a/manuscript/chapter4.txt +++ b/manuscript/chapter4.txt @@ -15,9 +15,14 @@ file_data="$(<"file")" Alternative to the `cat` command. ```shell -# Bash <4 +# Bash <4 (discarding empty lines). IFS=$'\n' read -d "" -ra file_data < "file" +# Bash <4 (preserving empty lines). +while read -r line; do + file_data+=("$line") +done < "file" + # Bash 4+ mapfile -t file_data < "file" ```