• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Solved Whats happening when I type ls and then press ^d?

clawhammer

Member

Thanks: 5
Messages: 91

#1
On the command line.

when I do it with ls command it displays: ls ls-F lsextattr lsvfs.

when I do it with cat command it displays: cat catman.

I'm reading The Unix Programming environment book and it says ^d sends the info to the program reading from the terminal.
 

aragats

Aspiring Daemon

Thanks: 287
Messages: 768

#2
Ctrl-D is EOF=End of File.
When you say "with ls" or "with cat", it's not correct: none of your commands is executed until you press Enter. Thus Ctrl-D is interpreted by your shell, in (t)csh it works as Tab - suggesting possible completions, in sh or bash it does nothing. In any shell if the command line is empty, the shell simply exits.
However, if you run a command which is awaiting for your input, pressing Ctrl-D sends EOF, and your command understands that you finished your input.
In your example if you type cat and press Enter, you can type text and press Enter over and over, and the text will be output until you press Ctrl-D.