How the shell implements i++ operations and string interception operations

Source: Internet
Author: User

These days there is a bug wrapped around me for half a day, so I have this article.

Touch screen because added a notebook keyboard can not be used, take off the notebook keyboard, touch screen can be used again, really ghost.

A little research, the original is added to the notebook keyboard caused by the TP drive device node changed, for example, before is event4, add a notebook keyboard after event6, resulting in the application used by the device node with the TP driver does not match.

So, I wonder, the previous method is in the compilation of the time to write dead, such as the configuration of 4, the runtime is set to 4, unchanged, in fact, this is a certain risk, such as the example just said. So, how to change it? Can you tell what the TP device node is when allowed? The answer is yes.

A little bit of a problem was encountered when adding the Event_num scheme to get TP automatically:

First, when traversing the device node, how to record the Event_num,c language is very simple ah, i++, but the shell can not do so.

Second, how to intercept the first few characters of the string?


Solve the first problem, search the Internet, found that there is a good person to write, here Quote:

a=1a=$ (($a + 1)) a=$[$a +1]a= ' expr $a + 1 ' let A++let a+=1
There are several ways to implement i++ operations, in which I use let a++ in practice


The second problem is actually a lot of ways, I just say one easy to remember:

For example: There is a string variable string=abcdefgh, I need to intercept the first 4 characters, then how should the shell be implemented?

string= "ABCDEFGH" cut_string= ' echo $string |cut-c 1-4 '
Results: CUT_STRING=ABCD

The above 2 problems are encountered in the actual problem solving, although the humble technical point, slowly accumulate or useful.

The old saying goes: Do not accumulate kuibu, not even thousands of miles, do not accumulate small stream, not to become Jianghai. O (∩_∩) o

How the shell implements i++ operations and string interception operations

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.