dingyichen (dingyichen) wrote,

Matching prefix pattern in Bash Parameter Expansion

According to bash manpage, when doing parameter expansion like


"The word is expanded to produce a pattern just as in pathname expansion."

Indeed, the pathname expansion is glob expansion, however, unlike normal pathname expansion, the '*' actually matches '/'. In other words:

echo ${PA##ja*}

outputs "",
instead of "/subdir/",
because ja* matches ja-JP/subdir/.

So please treat * as if it is '.*' in regex.
Tags: bash. parameter expansion
  • Post a new comment


    default userpic

    Your reply will be screened

  • 1 comment