Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Technical Support _ I need help with grep

Posted by: Roadhouse Sep 25 2012, 06:50 AM

I've been trying to figure out a few things with grep but I'm really stuck now.

1. I'm trying to grep anything that starts with an "a", but doesn't have any more "a":s. Which means that grep would show me words like "and", but not words like "america".

2. I'm trying to grep anything that doesn't contain "a" at all. I know it's easily done by using "grep -v a". However, I'm trying to do this without using "-v". I've tried things like "grep [^a]", but that would only remove things that contain "a" only. I've tried using * and .* but it doesn't help me at all.

Help is very appreciated!

Posted by: mogwin Nov 21 2012, 02:39 PM

Number 1 would best be accomplished by piping one grep to another:
grep ^[aA] ./filename | grep -v [aA].*[aA]

Number 2 would best be accomplished by using the -v option. Why are you trying to avoid using "grep -v [aA]"

Powered by Invision Power Board (
© Invision Power Services (