user5403847
user5403847

Reputation:

How to use regular expression in Linux to output number?

How do you output only the number of words in /usr/share/dict/words that begin with any letter, let's say j?

I was hoping to use egrep 'J*' /usr/share/dict/words, but does not work well.

Upvotes: 0

Views: 42

Answers (1)

Mad Physicist
Mad Physicist

Reputation: 114478

If your words are one on each line, then your solution is very close.

grep -ci '^j' /usr/share/dict/words

The ^ symbol means "start of line". -i flag means case insensitive search, -c means only report the count.

Upvotes: 2

Related Questions