Skip to content

Files

Latest commit

 

History

History
27 lines (16 loc) · 646 Bytes

SC2101.md

File metadata and controls

27 lines (16 loc) · 646 Bytes

Pattern: Missing outer [] for named class

Issue: -

Description

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.

Example of incorrect code:

gzip file[:digit:]*.txt

Example of correct code:

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

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:]'

Further Reading