Remove the First Capital Letter from Each Element

  • + 1 comment

    It's a simple pattern substitution, from "man bash":

    ${parameter/pattern/string} Pattern substitution. The 'pattern' is expanded to produce a pattern just as in pathname expansion. 'Parameter' is expanded and the longest match of 'pattern' against its value is replaced with 'string'. If 'pattern' begins with /, all matches of 'pattern' are replaced with 'string'. Normally only the first match is replaced. If 'parameter' is an array variable subscripted with @ or *, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.

    The '?' character stands for 'any' character. Probably it would be better written as:

    { a=($(cat)); echo ${a[@]/#[A-Z]/.}; }

    The first capital letter (only) will be replaced. (by @ariessa)