We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Whenever you use something like `$(command) in bash, you're creating a new sub-shell for that command. The input is obtained in that subshell, and the output replaces the entire $(command)` section in the original shell. Essentially think of it like executing a command first and then putting the ouput in place of the bracketed section.
Now, </dev/stdin is just redirecting the input from the subshell. So, whatever is entered in the subshell (sample inputs from the test-cases) gets sent (and replaces) $(</dev/stdin).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
A Personalized Echo
You are viewing a single comment's thread. Return to all comments →
Whenever you use something like
`$(command)
in bash, you're creating a new sub-shell for that command. The input is obtained in that subshell, and the output replaces the entire$
(command)` section in the original shell. Essentially think of it like executing a command first and then putting the ouput in place of the bracketed section.Now,
</dev/stdin
is just redirecting the input from the subshell. So, whatever is entered in the subshell (sample inputs from the test-cases) gets sent (and replaces)$(</dev/stdin)
.