Skip to main content
capitalization
Source Link
umläute
  • 6.7k
  • 2
  • 30
  • 54

soSo the problem is: why does a_[a-z]*_data match a_clean_0db_data?

thisThis can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

inIn regular expressions, [a-z]* would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

ifIf you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

theThe -maxdepth is only here to limit the search-results to the folder you are in. theThe regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expressions [a-z]* would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

So the problem is: why does a_[a-z]*_data match a_clean_0db_data?

This can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

In regular expressions, [a-z]* would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

If you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

The -maxdepth is only here to limit the search-results to the folder you are in. The regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

specified zero as part of the definition of * in reges...
Source Link

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expressionexpressions [a-z]* would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expression [a-z]* would mean any number of characters in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expressions [a-z]* would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

formatting, note that it's not all find implementations supporting that.
Source Link
Stéphane Chazelas
  • 586.4k
  • 96
  • 1.1k
  • 1.7k

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expression [a-z]* would mean *any number of characters in the range of a..z`any number of characters in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, you could usea few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expression [a-z]* would mean *any number of characters in the range of a..z`, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, you could use find:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

so the problem is: why does a_[a-z]*_data match a_clean_0db_data?

this can be broken down into four parts:

  • a_ matches the beginning of a_clean_0db_data, leaving clean_0db_data to be matched

  • [a-z] matches any character in the range a-z (e.g. c), leaving lean_0db_data to be matched

  • * matches any number of characters, e.g. lean_0db

  • _data matches the trailing _data

in regular expression [a-z]* would mean any number of characters in the range of a..z, but you are dealing with shell globbing, not with regular expressions.

if you want regular expressions, a few find implementations have a -regex predicate for that:

find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$" 

the -maxdepth is only here to limit the search-results to the folder you are in. the regular expression matches the entire filename, therefore I have added a ^.*/ to match the path-portion

explain find-args
Source Link
umläute
  • 6.7k
  • 2
  • 30
  • 54
Loading
Source Link
umläute
  • 6.7k
  • 2
  • 30
  • 54
Loading