Skip to main content

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

Another alternative is instead of [A-Z] to use brace expansion {A..Z} together with nullglob bash shopt option.

By enabling the nullblognullglob option, if a pattern is not matched during pathname expansion, a null string is returned instead of the pattern it selfitself.
As a result this one will work as expected:

$ shopt -s nullglob;printf '%s\n' {A..Z}* 

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

Another alternative is instead of [A-Z] to use brace expansion {A..Z} together with nullglob bash shopt option.

By enabling nullblog, if a pattern is not matched during pathname expansion a null string is returned instead of the pattern it self.
As a result this one will work as expected:

$ shopt -s nullglob;printf '%s\n' {A..Z}* 

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

Another alternative is instead of [A-Z] to use brace expansion {A..Z} together with nullglob bash shopt option.

By enabling the nullglob option, if a pattern is not matched during pathname expansion, a null string is returned instead of the pattern itself.
As a result this one will work as expected:

$ shopt -s nullglob;printf '%s\n' {A..Z}* 
added 356 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

Another alternative is instead of [A-Z] to use brace expansion {A..Z} together with nullglob bash shopt option.

By enabling nullblog, if a pattern is not matched during pathname expansion a null string is returned instead of the pattern it self.
As a result this one will work as expected:

$ shopt -s nullglob;printf '%s\n' {A..Z}* 

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

Another alternative is instead of [A-Z] to use brace expansion {A..Z} together with nullglob bash shopt option.

By enabling nullblog, if a pattern is not matched during pathname expansion a null string is returned instead of the pattern it self.
As a result this one will work as expected:

$ shopt -s nullglob;printf '%s\n' {A..Z}* 
added 552 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43

In bash version 4.3 and later, there is ana shopt option called globasciiranges that if enabled equals:

According to C locale.shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

In bash there is an option globasciiranges that if enabled equals to C locale.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

In bash version 4.3 and later, there is a shopt option called globasciiranges :

According to shopt builtin gnu man pages:

globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

As a result you can

$ shopt -s globasciiranges $ echo [A-Z]* 

Use shopt -u for disabling.

Another way is to change locale to C. You can do this temporarily using a subshell:

$ ( LC_ALL=C ; printf '%s\n' [A-Z]*; ) 

You will get the results you need, and when the sub shell is finished, the locale of your main shell remains unchanged to whatever was before.

added 283 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43
Loading
Post Undeleted by George Vasiliou
deleted 124 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43
Loading
Post Deleted by George Vasiliou
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43
Loading