Skip to main content
Agree with removing second example as it's duplicate but first example shows problem is not present in GNU grep 2.27
Source Link
brendan
  • 195
  • 9

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z]test]$ ../../test
CCgrep cc-V
[aa@bb src]$GNU grep [A-Z] 2.6./3
../test
aa bb
CC cc
dd ee.
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ ./grep [A-V
GNU grepZ] 2.6.3
./../test
CC cc
[aa@bb src]$ 
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ grep [A-Z] ../../test
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ 
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$
Rollback to Revision 3
Source Link
brendan
  • 195
  • 9

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ grep [A-Z] ../../test
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ grep [A-Z] ../../test
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$
The "test" examples weren't adding anything new
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ grep [A-Z] ../../test
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep [A-Z] ../../test
CC cc
[aa@bb src]$ grep [A-Z] ../../test
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or something else?

[aa@bb grep-test]$ cat input.txt
aa bb
CC cc
dd ee

[aa@bb grep-test]$ LC_ALL=C grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ grep -o [A-Z] input.txt
C
C
[aa@bb grep-test]$ LC_ALL=C grep [A-Z] input.txt
CC cc
[aa@bb grep-test]$ grep [A-Z] input.txt
aa bb
CC cc
dd ee
[aa@bb src]$ ./grep -V
grep (GNU grep) 2.27
...
[aa@bb src]$ grep -V
GNU grep 2.6.3
...
[aa@bb src]$
[aa@bb grep-test]$ grep a input.txt
aa bb
[aa@bb grep-test]$ grep C input.txt
CC cc
[aa@bb grep-test]$ locale
LANG=en_IE
LC_CTYPE="en_IE"
LC_NUMERIC="en_IE"
LC_TIME="en_IE"
LC_COLLATE="en_IE"
LC_MONETARY="en_IE"
LC_MESSAGES="en_IE"
LC_PAPER="en_IE"
LC_NAME="en_IE"
LC_ADDRESS="en_IE"
LC_TELEPHONE="en_IE"
LC_MEASUREMENT="en_IE"
LC_IDENTIFICATION="en_IE"
LC_ALL=
[aa@bb grep-test]$ grep -V
GNU grep 2.6.3
...
[aa@bb grep-test]$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
...
[aa@bb grep-test]$ xxd input.txt
0000000: 6161 2062 620a 4343 2063 630a 6464 2065  aa bb.CC cc.dd e
0000010: 650a 0a                                  e..
[aa@bb grep-test]$ cat -A input.txt
aa bb$
CC cc$
dd ee$
$
[aa@bb grep-test]$
added 262 characters in body
Source Link
brendan
  • 195
  • 9
Loading
added 298 characters in body
Source Link
brendan
  • 195
  • 9
Loading
Source Link
brendan
  • 195
  • 9
Loading