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
  • 55,929
  • 26
  • 146
  • 227
shawn edward
  • 473
  • 3
  • 13
  • 17
  • 1
    why are you piping `ls` to `grep` **AND** giving `grep` a filename to process? – cas Mar 06 '16 at 06:33

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
  • 54,820
  • 8
  • 124
  • 141