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

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.
 
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.
 
Back
Top