3 ms·
I guess it's equivalent to `: <file` i.e. hooking up the stdin of the no-op command.
by frou_dh 3y ago
I guess it's equivalent to `: <file` i.e. hooking up the stdin of the no-op command.
- xigoi 3y agoDoesn't seem to be the case. For example, `< file cat` shows the file, whereas `: < file cat` or `: < file | cat` does nothing.
- frou_dh 3y agoNot sure what's surprising you in those snippets. `:` itself is a command and it does nothing with its arguments or stdin. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_16 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
- xigoi 3y agoI know. The only thing surprising me is your previous claim that `< file` is equivalent to `: < file`.
- frou_dh 3y agoMy interpretation of sgarland's question was that he meant `<file` being the entirety of the statement, i.e. typing only that at a shell prompt and pressing return.
- xigoi 3y agoAh. Now I understand where the misunderstanding was. It confused me that we were talking about redirection as a replacement for useless use of cat.
- frou_dh 3y agoYep I can appreciate the misunderstanding. For completeness of the discussion, I think where sgarland mentioned a sub-shell, he was possibly referencing the Bashism `$(<` detailed on this page https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html https://www.gnu.org/software/bash/manual/html_node/Command-S... in addition to what I called a "statement" above.
- sgarland 3y agoCorrect, that’s what I had in mind.