Which of the following commands outputs test to the shell?
Which of the following commands outputs test to the shell?
The correct command to output 'test' to the shell is to use a 'heredoc' in the form of 'cat <<eot'. This directs the shell to receive input until it encounters the delimiter 'EOT'. In this case, the input 'test' will be sent to 'cat', which then outputs 'test' to the shell when the 'EOT' delimiter is reached, ending the input.
the command is cat << EOT >test >EOT
bash 'heredoc' for research.
E is correct #cat <<ENDofTEXT >test >ENDofTEXT
None worked for me on Ubuntu. Anyone can explain why E would be correct? I prompts input when you run the string
with EOT [enter] you start an input of text. you'll get a new line to type your text and can add lines by pressing enter. afterwards you close the input with another EOT that will output the whole text in between those EOTs. the cat << will put that output into your shell, like a print
its just a kind of label. you can use any word in that place. some popular usage are ftp, database processing etc. Code: ftp -inv $host << FTP ## start of label, below command will be treated as ftp command not the shell commans user $user $passwd bin put $file bye FTP # end of ftp commands ls ## shell commands again https://www.unix.com/shell-programming-and-scripting/128056-command-eot.html
Tested for sure E, EOT can be anything i.e. Linux as long as it is typed last to end the text input