A Personalized Echo

Sort by

recency

|

144 Discussions

|

  • + 0 comments

    read name printf "Hello %s\n" "$name"

  • + 0 comments

    read name echo "Welcome $name"

  • + 0 comments

    sed -e 's/^/Welcome /;q' -

  • + 0 comments
    read name; echo "Welcome $name"
    
  • + 0 comments

    I know this is a beginner-level challenge, but I'm surprised the test cases are so kind. The echo command does not emit all its input completely literally—it will transform escaped characters, for example. And feeding the input through read and then double-quoted string can mangle things too.

    $ read name; echo "Welcome $name"
    \n\tChuckles\n\t
    Welcome ntChucklesnt
    
    $ printf 'Welcome %s\n' $(cat)
    \n\tChuckles\n\t
    Welcome \n\tChuckles\n\t