Delete and replace Environment Variables

Source: Internet
Author: User
[Root @ rhel6-server ~] # Echo $ {mail} # output mail Environment Variables
/Var/spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail #/*/} # match the shortest string starting with/and ending with/from the beginning, locate it, and delete it.
Spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail ###/*/} # match the longest string starting with/and ending with/from the beginning, locate it, and delete it
Root
[Root @ rhel6-server ~] # Echo $ {mail %/*/} # from the end, match the shortest string starting with/and ending with/, locate it, and delete it.
/Var/spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail %/*} # starting from the end, match the shortest string that starts with any character and ends with/, locate it, and delete it.
/Var/spool/mail
[Root @ rhel6-server ~] # Echo $ {mail %/*} # starting from the end, match the longest string that starts with any character and ends with/, locate it, and delete it.

[Root @ rhel6-server ~] # Echo $ {mail % L *} # starting from the end, match the longest string starting with any character and ending with L, locate it, and delete it
/Var/spoo
[Root @ rhel6-server ~] # Echo $ {mail/l/L} # match the first l from the beginning and replace it with L after finding it
/Var/spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail // L/L} # starting from the beginning, match all L, find it, and replace it with L
/Var/spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail/OO} # match the first Oo from the beginning, find it, and replace it with OO
/Var/spool/mail/root
[Root @ rhel6-server ~] # Echo $ {mail // oo/OO} # From the beginning, match all Oo, and replace it with OO
/Var/spool/mail/root

Summary:

# Delete the string from the beginning to match the minimum matching string

# Delete from the beginning to match the longest matching string

% Start deleting from the end and match the string with the shortest match

% Start deleting from the end and match the longest matching string

/Replace the first matched string

// Replace all matched strings

Ref:

Change the division, substitution, and replacement of data content

Http://linux.vbird.org/linux_basic/0320bash.php#variable_other

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.