From 007b8b524c68d6a5895a1aae0cae31937aa0acbf Mon Sep 17 00:00:00 2001 From: koalaman Date: Mon, 24 Feb 2014 18:00:19 -0800 Subject: [PATCH] Created SC2101 (markdown) --- SC2101.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SC2101.md diff --git a/SC2101.md b/SC2101.md new file mode 100644 index 0000000..a43d994 --- /dev/null +++ b/SC2101.md @@ -0,0 +1,17 @@ +# 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. + +### Contraindications + +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:]'` \ No newline at end of file