1

I need to list lines that consist of a single non-vowel character.

I got this:

ls | grep -nv '[aeiouy]' file

But this doesn't give me a single character. How do I get just a single character?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

1 Answers1

2

Just add x to match the whole line:

grep -nvx '[aeiou]' file.txt

Or

grep -nv '^[aeiou]$' file.txt

Or

grep -nx '[^aeiou]' file.txt

Or

grep -n '^[^aeiou]$' file.txt

Note that, parsing ls is not a good idea.

heemayl
  • 56,300