help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf '%s\n' "$@" versus <<< redirection


From: Kerin Millar
Subject: Re: printf '%s\n' "$@" versus <<< redirection
Date: Sun, 19 Feb 2023 10:38:22 +0000

On Sun, 19 Feb 2023 10:00:17 +0000
goncholden <goncholden@protonmail.com> wrote:

> while IFS='\n' read -r vl

This does not behave in the way that you think. IFS is used for field 
splitting, not to determine where a record ends (that's what the -d option is 
for).

$ printf 'n\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl=""

$ printf '\\\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl=""

$'\n' would have expanded as an actual LF character but it would not be useful 
to you. To read each line verbatim, set IFS to the empty string instead. Also, 
see "help read", the bash manual and https://mywiki.wooledge.org/BashFAQ/001.

-- 
Kerin Millar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]