Timeline for Exclude one pattern from glob match
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 24, 2021 at 21:28 | answer | added | Kusalananda♦ | timeline score: 6 | |
| May 6, 2021 at 20:18 | answer | added | GigaWatts | timeline score: 1 | |
| Jul 5, 2018 at 20:01 | answer | added | Adobe | timeline score: 15 | |
| Nov 28, 2015 at 18:10 | answer | added | mivk | timeline score: 48 | |
| Oct 24, 2014 at 17:33 | comment | added | Johnny |
@jbarker2160 - that's not really a regular expression, it's more commonly called a glob (or filename pattern), which is more or less a subset of a regular expression - see the pattern matching section of the bash manpage for details. His pattern foo.*[^org] will match any filename that begins with foo. with one or more characters after the dot where the last character is not o, r, or g. So it would match foo.orb, but not foo.org or foo.or or foo.o. GlennJackman's answer shows how to enable extended pattern matching features to negate a match.
|
|
| Oct 24, 2014 at 17:16 | comment | added | Mr. Mascaro |
You are using a Regular Expression. You should be careful with your grouping characters. By using brackets you've specified a character class meaning that you would delete any files that had an extension with the letters o,r or g in any order. Use parenthesis to create a group and preserve the order of characters.
|
|
| Oct 24, 2014 at 16:46 | history | tweeted | twitter.com/#!/StackUnix/status/525689860846137344 | ||
| Oct 24, 2014 at 16:04 | comment | added | jimmij |
As an addition to @glen answer it is worth to mention that rm foo.*[^org] removes all files which last character is neither o, r or g, so foo.foo wouldn't match either.
|
|
| Oct 24, 2014 at 15:48 | vote | accept | jake | ||
| Oct 24, 2014 at 15:35 | answer | added | glenn jackman | timeline score: 131 | |
| Oct 24, 2014 at 15:29 | history | asked | jake | CC BY-SA 3.0 |