Originally Posted by cliffyao
Thanks for your quick response. I slightly modified your command to
awk '$2 ~ /[a-z]/' input.txt > output.txt
And the output.txt is the same as the input.txt..
I understood that you were using regular expression so I googled and changed the command again to
awk '$2 ~ /[[:lower:]]/' input.txt > output_lower.txt
awk '$2 ~ /[[:upper:]]/' input.txt > output_upper.txt
And now, it works.
Although I got what I wanted now, I am still curious why [a-z] can't work in my case.
Also, I noticed that I had to use double-quoted [[:lower:]] to make it work. I am wondering why single quote can't work. I searched regular expression online and it looks like
[:upper:] Any alpha character A to Z.
[:lower:] Any alpha character a to z.
Why a-z didn't work for you I can't answer, maybe an
encoding thing? As for the [[ ... that's a requirement.
[:lower:] is the equivalent of a-z on ASCII or iso8859-1
system - note that a-z there doesn't have the  around
it; hence you still need the outer square bracket to make
it a range.