Some error occured while loading page for you. Please try again.
Sort 25 Discussions, By:
Please Login in order to post a comment
Why is the read syntax the only correct answer to this question? Why not the $1 alternative?
The input comes from stdin, not comand line arguments
Humm, thanks, didn't know this only correct answere i did also it with $1 with no success .. theses tests are limited
echo "Welcome Dan"
I don't understand why they had to write "script which accepts" instead of "script which reads.
printf "Welcome "
sed -r 's/(.*)/Welcome \1/g'
Hi! I'm new to this. Can you please explain a bit this command?
I'm capturing the contents of stdin using (.*) regexp which can be referenced using \1 where \1 refers to 1st captured group and then prepending the text with "Welcome".The syntax is s/[text]/[replacement]/
Got it. Thanks!
new to shell, very incredible
here is the answer:
echo "Welcome $name"
echo "Welcome $(</dev/stdin)"
will also work
Can you explain this a bit, please?
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).
I wrote exactly the same thing but it keeps saying it's wrong !!
I have a tick in every test case but when retunr back to the bash tutorials page it doesnt show thus question as fully solved?
checking this; it's a bug on our end. will fix
bug still not fixed
can you please check now? It will be fixed.
3 years and it still hasn't been fixed.
same here :(
xargs -I ^ echo "Welcome" ^
echo $str1 $test
One new solution: sed -r 's/\w+/Welcome &/g'
the input parameter comes from stdin, not from comand line arguments
in this case, this code is wrong:
echo "Welcome $1
but this works well:
echo "Welcome "`cat -`
Can you explain the cat and the '-'.