SoFunction
Updated on 2025-04-10

Another good batch bat learning tutorial page 3/5


Let’s start with the pipeline commands. Commonly used pipeline commands are as follows: |, >, >>

" |" This command is probably not unfamiliar with everyone. Friends who often operate DOS should know that when we view the help of a command, if the help information is relatively long and one screen cannot be displayed, DOS does not give us time to finish reading one screen and then turn to another screen, but directly displays it to the end of the help information. If you enter help to enter at the prompt, you will see all non-implicit commands supported by the current DOS version, but you can only see the last commands. The previous one has already flashed by. How to solve this problem?

See the following example:

help | more 

After entering the car, you will find that the screen will automatically pause after the display is full, waiting to continue to display other information. When pressing Write Enter, it becomes one by one; when pressing the space bar, it is displayed on one screen until all of them are displayed; pressing other keys to automatically stop returning to DOS.

Why does the above phenomenon occur? The answer is very simple. Here we combine the pipeline command "|" and the DOS command more to achieve the goal together. Here I will briefly introduce the help command and more command, which will be of great help to understand the usage of the "|" command.

help command: Actually, this command does not need to be said more, but in the above example, the use of the help command is quite special. You can directly enter the help command at the DOS prompt. The result is that DOS can display all the non-implicit commands it supports. When using the help command in other places, such as entering net help enter, it will display the help information of the net command.

more command: Many friends may not have contacted this command before. This command is very widely used in Linux and is also one of the pipeline commands. You can find a longer article () and enter the following two commands at the DOS prompt to compare the differences: more  and type . Using the more command, you can achieve the effect of displaying output screen-by-screen or line-by-line, while the type command can only display the output at once. The final result is that you can only see the end part. In the above example, the function of the more command is to display the output information screen or line by line.
Seeing this, can you vaguely feel the effect of the "|" command? Yes, its function is to use the output of the previous command as the input of the next command. In this example, the output of the previous command is all non-implicit commands supported by DOS displayed after the help command is executed, and this result just makes the input of the next command more. So it is equivalent to the following example:

help >  
more  
del  

Here, another pipeline command is used > a file is generated as an intermediate link. After viewing the file with the more command, the file is deleted (all operations in this example are performed in memory and no files are generated). It can be seen that correctly using the pipeline command "|" can bring twice the result with half the effort.
Previous page12345Next pageRead the full text