Article Title: how to extract desired parameters from Unix results. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
For most Unix operating system commands, detailed parameters are output after the command is executed. However, sometimes System engineers may not need such detailed information. For example, the date command displays the time, date, number of years, and other information. However, when developing some applications, system engineers may only need time information. Therefore, some tools need to be used to extract relevant parameter information. In fact, this situation is not only encountered in Unix system management, but also in development platforms of some other programs. Other platforms use string truncation or other similar methods. In Unix systems, some professional commands are provided to operate on location parameters. Such as the set and shift commands.
Before introducing the usage of these two commands, I will show you one. As shown in, this figure uses the set command to operate on location parameters. Extract some results from the date command. This feature not only formats the display results, but also makes it useful to develop some applications in shell.
1. Introduction to the set command.
In Unix systems, the set command is a very useful system command, which can help the system administrator to meet many requirements, such as setting environment variables. Here, it is mainly used to implement this location parameter. In fact, there are many methods in Unix systems that can be used to extract specific parameters from command results. For example, you can use the external command cut to extract the content of a field from an output result. However, if you use the cut command to implement this function, it seems a bit amateur. Since the Unix operating system provides other more professional commands to implement these functions, why should System Engineers stay away?
In fact, some internal commands are provided in the standard shell of Unix systems to implement functions. The set command is a representative command. The Set command can assign parameters to location parameters such as $1 and $2. If the system engineer needs to extract some content from the output result of the program, this command is often used.
[1] [2] [3] Next page