[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