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?

  • 1
    why are you piping ls to grep AND giving grep a filename to process? – cas Mar 6 '16 at 6:33
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.

  • @shawnedward The others should work too..could you please add your input file.. – heemayl Mar 6 '16 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.