Find the answer to your Linux question:
Results 1 to 3 of 3
Hello! I've been trying to figure out a few things with grep and uniq but I'm really stuck now and would really need some help. 1. I'm trying to grep ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2012
    Posts
    1

    I need some help with grep and uniq


    Hello!
    I've been trying to figure out a few things with grep and uniq but I'm really stuck now and would really need some help.

    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.

    3. I have a file containing two rows of words, and it looks something like this:

    cat noun
    cat noun
    dog noun
    eat verb
    bow noun
    bow noun
    bow verb

    Now, what I want to do is to sort out all words that are the same, but have different word classes. So 'cat', 'dog' and 'eat' should be sorted out since both are nouns, Which means I want the output to be:

    bow noun
    bow verb

    I've tried using uniq and sort in every way i could think of, but I still can't sort this out. There's a TAB between the words, if the cut command could be of any help.

    Help is very appreciated!!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,539
    Stupid question, but is this a class/school exercise/problem?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Until I hear whether or not this is homework, I'm going to withhold too much detail, but my main question is: why don't you want to use grep -v?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •