Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 6 revisions

Named class needs outer [], e.g. [[:digit:]].

Problematic code:

gzip file[:digit:]*.txt

Correct code:

gzip file[[:digit:]]*.txt

Rationale:

Predefined character groups are supposed to be used inside character ranges. [:digit:] matches one of "digt:" just like [abc] matches one of "abc". [[:digit:]] matches a digit.

Exceptions

When passing an argument to tr which parses these by itself without relying on globbing, you should quote it instead, e.g. tr -d '[:digit:]'

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally