Skip to content

Instantly share code, notes, and snippets.

@douglasnaphas
Created August 6, 2015 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglasnaphas/e3f94805c8ffe9a5744f to your computer and use it in GitHub Desktop.
Save douglasnaphas/e3f94805c8ffe9a5744f to your computer and use it in GitHub Desktop.
Why does awk print letters not between A and Z in the ASCII character set when told to print lines that match the regex [A-Z]?
$ echo "b" | awk '/[A-Z]/'
b
$ echo "a" | awk '/[A-Z]/'
$ echo "z" | awk '/[A-Z]/'
z
$
@jrosen
Copy link

jrosen commented Aug 6, 2015

I'm guessing case matters. Try [a-zA-Z]

@jrosen
Copy link

jrosen commented Aug 6, 2015

Wait. I misread. Nevermind

@sgoguen
Copy link

sgoguen commented Aug 7, 2015

Sorry, I can't get this to reproduce on my machine. My awk (the default ubuntu docker image) is case sensitive by default. When I force case sensitivity:

echo "a" | awk 'IGNORECASE = 1;/[A-Z/'

I get the correct output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment