How to extract desired parameters from Unix results

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.