Bash Reference Mamual

2020-10-17 Thread Craig H Maynard
Hi,

In section 3.5.4 "Command Substitution", the following sentence may have a typo:

> The command substitution $(cat file) can be replaced by the equivalent but 
> faster $(< file).


My proposed change:

> The command substitution $(cat file) can be replaced by the equivalent but 
> faster <(cat file).


If the manual is correct and I misunderstood something, please let me know.

Thanks,
Craig

--
Craig H Maynard
103 North Road
Wakefield, RI 02879
(401) 413-2376




Re: Bash Reference Mamual

2020-10-18 Thread Craig H Maynard
I get it now. Thanks for your friendly and informative replies. :)

Craig


> On Oct 17, 2020, at 7:45 PM, Lawrence Velázquez  wrote:
> 
>> On Oct 17, 2020, at 7:35 PM, Eduardo Bustamante  wrote:
>> 
>> <(cat file) and $(cat file) are not equivalent constructs. The former will
>> expand to a file name (e.g. "/dev/fd/63"), whereas the latter will expand
>> to the contents of the file.
> 
> If you want terms you can look up, $(cat file) and $(< file) are
> *command substitutions*, while <(cat file) is a *process substitution*.
> 
> $ printf 'FILE CONTENTS' >tmp
> $ printf '|%s|\n' "$(cat tmp)"
> |FILE CONTENTS|
> $ printf '|%s|\n' "$(< tmp)"
> |FILE CONTENTS|
> $ printf '|%s|\n' "<(cat tmp)"
> |<(cat tmp)|
> $ printf '|%s|\n' <(cat tmp)
> |/dev/fd/63|
> 
> 
> --
> vq