help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Why `$(<` is slow?


From: Stephane Chazelas
Subject: Re: [Help-bash] Why `$(<` is slow?
Date: Fri, 30 Aug 2019 18:23:58 +0100
User-agent: NeoMutt/20171215

2019-08-30 11:58:26 -0500, Peng Yu:
> > Note that IFS= read -rd '' x (you forgot the IFS= btw)
> 
> What is the difference between `IFS= read -r -d '' x` and `read -r -d
> '' x`? I can not make an example to show the difference. Do you have
> an example? Thanks.
[...]

See for instance
https://unix.stackexchange.com/questions/209123/understanding-ifs-read-r-line

Compare:

$ printf '\n \tqwe\n \t\0' | bash -c 'read -rd "" x; printf "<%q>\n" "$x"'
<qwe>
$ printf '\n \tqwe\n \t\0' | bash -c 'IFS= read -rd "" x; printf "<%q>\n" "$x"'
<$'\n \tqwe\n \t'>

See also:

$ printf 'foo:' | bash -c 'IFS=:; read -rd "" x; printf "<%q>\n" "$x"'
<foo>
$ printf 'foo:' | bash -c 'IFS=:; IFS= read -rd "" x; printf "<%q>\n" "$x"'
<foo:>

-- 
Stephane





reply via email to

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