Understanding the Behavior of Cat Running on Bash (Linux)

Asked 2 years ago, Updated 2 years ago, 121 views

If you use Bash on Cloud9 and type cat as shown in the attached image, proceed to the next line without any response.So even if you type -a, it's just a new line.When I pressed Enter, a blank line appeared.Could you tell me what this means?

Bash image

bash unix shell

2022-09-29 22:44

3 Answers

cat is a command that says

  • Outputs the input from the standard input exactly as it is in the standard output
  • Outputs the contents of the specified file (instead of standard input) to standard output (combined)

In this operation example, the cat command was launched without a filename, so the operation is the former.
No redirect, so the standard input is a keyboard and the standard output is a screen.
That's why I'm performing the operation of "printing the input directly from the keyboard onto the screen."

To get EOF from the keyboard ctrl-D on Linux ctrl-Z on Windows
This time ctrl-C is given, so it is not terminated normally, but forced to stop.


2022-09-29 22:44

The cat command is a concatenation of the contents of the text file specified in the argument.
By default, one or more existing files are often run with arguments.

$cat FILE1.txt
$ cat FILE1.txt FILE2.txt

In the example run, no file was specified for the argument, so it is waiting to be entered.
The characters that you typed themselves are displayed on the screen.


2022-09-29 22:44

It's not bash.On the first line, run the cat command, which prints the characters exactly as they are entered.The termination of the input is recognized by the Ctrl+D key.


2022-09-29 22:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.