running cat without a direction
- Anmelden oder Registrieren um Kommentare zu schreiben
I've been messing with my terminal and I've come across something I don't understand. if I run $ cat on it's own, I am booted from any working environment. Can some explain what's going on?
> if I run $ cat on it's own, I am booted from any working environment.
> Can some explain what's going on?
What do you mean by "booted from"? When I run `cat` without any
arguments, it just hangs until I cancel the command with Ctrl+C.
cancelling the command, I guess that's what I was indirectly trying to learn here. thanks!
When you call cat without arguments, it expects to get the input from standard input, which means from your keyboard.
so is it just waiting for a further command? or is it actually running the cat program somehow?
'cat' is running. It is waiting for you to type the content to write to the standard output (the terminal, if not redirected) because you have not given it any file(s) in argument(s) and because, as always for POSIX commands, the standard input (the keyboard, if not redirected) is the default. That content is processed line after line (try writing any line, type [Enter], and that line is written to the standard output) until the EOF character (EOF stands for "End Of File") is read (you can input it with Ctrl+D, and the line you started is written to the standard output) or until 'cat' is abruptly interrupted (you can do so with Ctrl+C, which sends the SIGINT signal to the process, and the line you started is NOT written to the standard output).
So, for instance, you can create in the working directory a text file named "test" and containing:
Hello, world!
I am Magic Banana.
(with no newline after the dot) by executing:
$ cat > test
(> redirects the standard output to the file "test") and typing:
Hello, world![Enter]
I am Magic Banana.[Ctrl+D]
To display the two-line content of "test" ('wc' actually reports one single line because the second line does not end with a newline character):
$ cat test
excellent magic banana!
- Anmelden oder Registrieren um Kommentare zu schreiben