bash shell miscellaneous notes (2) results and process output

After a script is executed, if no output can be generated, the execution result cannot be seen, and the execution process cannot be seen. I don’t know whether the execution is successful. It's worth it, but for a long time, input and output have been a headache. In this chapter, I will briefly talk about output based on my understanding.

type of output ``

There are too many types of output. Writing to the screen is not the same as writing to a file, at least it certainly looks different. Writing to a file is also different than writing to tape or flash. What if you want the output of one program to go directly to another? Do software developers write code for a variety of output devices, even devices that haven't been invented yet? This is obviously a hassle. Don't users also have to know how to connect the programs they want to run to different kinds of devices? It's not a very good idea either.
One of the most important concepts behind the Unix operating system is that everything is a file (an ordered sequence of bytes). The operating system is responsible for performing this magic. Whether the target you want to write to is a disk file, terminal, tape device, memory stick, or something else, the program only needs to know how to
write the file, and the rest is done by the operating system. This approach greatly simplifies the aforementioned problems. So since they are all files, the next question comes, which file to write to? How does a program know whether to write to a file representing a terminal window, a disk file, or some other kind of file? It's not difficult, just leave this kind of thing to the shell.
See the following command
do some work < inputfile > outputfile
This command reads input from inputfile and sends output to outputfile. If >outputfile is omitted, the output is to the terminal window. If <inputfile is omitted, the program accepts input from the keyboard. The program really doesn't know where its output goes, nor where it gets its input from. You can use bash's redirection feature to convert the input

Guess you like

Origin blog.csdn.net/mainmaster/article/details/131480478