Kyle Chen's Blog

Action speaks louder than Words

0%

Linux Command —— Wildcard

* asterisk

  • this can represent any number of characters (including zero, in other words, zero or more characters). If you specified a “cd*” it would use “cda”, “cdrom”, “cdrecord” and anything that starts with “cd” also including “cd” itself. “m*l” could by mill, mull, ml, and anything that starts with an m and ends with an l.

  • ? question mark

  • this can represent any single character. If you specified something at the command line like “hd?” GNU/Linux would look for hda, hdb, hdc and every other letter/number between a-z, 0-9.

    [] square brackets

  • specifies a range. If you did m[a,o,u]m it can become: mam, mum, mom

    [-] minus sign in the square brackets

  • if you did: m[a-d]m it can become anything that starts and ends with m and has any character a to d in between. For example, these would work: mam, mbm, mcm, mdm. This kind of wildcard specifies an “or” relationship (you only need one to match).

    [^] Exponential sign in the square brackets

  • if you did: m[a-d]m it can become anything that starts and ends with m and has any character excepts a to d in between.