cmc-csci143 icon indicating copy to clipboard operation
cmc-csci143 copied to clipboard

Question about Quiz Practice: Shell 1

Open danzhechen opened this issue 1 year ago • 1 comments

I am a bit confused regarding the result of Problem 19. @mikeizbicki

I typed in the command and got the result: echo.

lambda-server:~/quiz $ cd; rm -rf quiz; mkdir quiz; cd quiz
lambda-server:~/quiz $ var=$(echo $(echo echo))
lambda-server:~/quiz $ touch "$var"
lambda-server:~/quiz $ ls
echo

I wonder whether the result to be echo instead of 'echo', since the result from Problem 15 to Problem 18 are all including single quotes. Is that because echo is a single word?

danzhechen avatar Jan 24 '24 01:01 danzhechen

Correct. ls adds the single quotes around the output only when there is a space in the filename. If there is no space in the filename, no quotes are added.

mikeizbicki avatar Jan 24 '24 04:01 mikeizbicki