In bash it's possible to put a file as an argument using the form "$(< file)"
. Where is the documentation for the presumably special casing of $(<
?
Asked
Active
Viewed 1,008 times
1

Matt Joiner
- 112,946
- 110
- 377
- 526
-
man manual mentioned it. – Shiping Jan 23 '17 at 01:48
-
1Did you try simply looking for `$(<` in the `bash` manual? – Barmar Jan 23 '17 at 01:49
-
I'm having a little trouble understanding the question. Are you trying to get the FILENAME in a variable or get the CONTENTS of a file into a variable? I don't understand what you want to do. – Thomas Hedden Jan 23 '17 at 01:49
1 Answers
3
It's in the man page, under "Command substitution":
Command Substitution
Command substitution allows the output of a command to replace the com-
mand name. There are two forms:
$(command)
or
`command`
Bash performs the expansion by executing command in a subshell environ-
ment and replacing the command substitution with the standard output of
the command, with any trailing newlines deleted. Embedded newlines are
not deleted, but they may be removed during word splitting. The com-
mand substitution $(cat file) can be replaced by the equivalent but
faster $(< file).

Benjamin W.
- 46,058
- 19
- 106
- 116

chepner
- 497,756
- 71
- 530
- 681