Unix Command to Find Uppercase Letters

Asparagus

Senior member
Aug 16, 2001
284
1
81
Hi all,

Let's assume I have a file named input.txt. I am in need of a Unix/Linux command that will "count the number of lines in the file that do NOT contain an uppercase letter".

I've been trying out all sorts of grep commands, but I can't seem to find one that does the job. I know grep -c will count the number of lines for me - just how do I do a search on each line for an uppercase letter???

Thanks.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
egrep -c '^[^A-Z]*$' input.txt

egrep -c
count the number of lines

[^A-Z]
with ONLY non-capital letters

*
or simply nothing

^
starting at the beginning of each line

$
to the end of it

... (i.e. the whole line)

input.txt
in the file "input.txt"
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: BingBongWongFooey
Hm that does make more sense (the [A-Z] part).

grep -vc [A-Z] input.txt

Piping to wc might be a bit more standard, since I'm not sure of the grep used on non OpenBSD or Linux. ;)