Method for getting substrings in Shell

Source: Internet
Author: User
Method 1 for getting substrings in Shell simple common method $ exprsubstr & quot; linuxsong & quot; 15linux2 direct variable truncation $ a & quot; linuxsong & quot; $ echo $ {: 0: 5} use cut to intercept the string $ echo & quot; linuxsong & quot; | method 1 to obtain the substring in c Shell. common method $ expr substr "linuxsong" 1 5 linux 2. intercept $ a = "linuxsong" $ echo $ {a: 0: 5} linux 3. use cut to intercept the string $ echo "linuxsong" | cut-c 1-5 # use the 1-5 characters linux 4. awk substring $ echo "linuxsong" | awk '{print substr ($, 5)} 'Linux 5. head substring $ echo "linuxsong" | head-c5linux 6. tail method 7. echo "hello" | tr' [a-z] ''[A-Z]'' for case-insensitive sed method conversion
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.