Use AWK to separate and intercept strings

Source: Internet
Author: User
Use $0 to split the current string. for example, catnum.2012032911 | awk & amp; #39; {print $2} & amp; #39; | awk & amp; #39; {split ($0, B, & quot ;. & quot;); printb [2]} & amp; #39; | cut-c3-get the second column, for example, the second column is com. sb3456.y
Use $0 to split the current string. for example, cat num.2012032911 | awk '{print $2}' | awk '{split ($0, B ,". "); print B [2]} '| cut-c 3-get the second column, for example, the second column is com. sb3456.you, then obtain sb3456 from the current split string, and finally extract the sb3456 string from 3rd characters to the final result of 456 B = "c, d, e, f, g "echo | awk '{split ("' $ {B} '", array ,","); print array [1]} 'c echo $ B | cut-d ","-f2 d -www.2cto.com-where-d represents what is used for segmentation, -f2 indicates that 2nd results are required. another common parameter is-c, use-cx-y this means to get the echo "abcdefg" from the x to the y string | cut-c3-6 output is def formatted column-t but it seems to be mixed with tabs and spaces the condition cannot be processed string =/home/bozo/daily-journal.txt to intercept the specified string -www.2cto.com-echo | awk '{print substr ("' $ {string }'", 2, 4)} '// Obtain the length of the 4 characters starting from 2nd characters. The result is: home calculates the string length echo | awk' {print length ("'$ {string }'")} '// The result is: 29 string case-insensitive conversion echo | awk' {print toupper ("test"), tolower ("TEST")} '. The result is: MyEyeOfJava, author of TEST.
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.