Find the answer to your Linux question:
Results 1 to 9 of 9
I'm looking to write a sample shell script that counts the number of distinct words in a text file given as Argument. Remark: White space characters are spaces, tabs, form ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6

    counts the number of distinct words

    I'm looking to write a sample shell script that counts the number of distinct words in a text file given as Argument.
    Remark: White space characters are spaces, tabs, form feeds, and new lines.

    JUST with this commands tr, sort, grep. wc.

    Thanks.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    JUST with this commands tr, sort, grep. wc.
    That's a pretty arbitrary limitation, but it sure makes for a good assignment. It tests your ability to come to a conclusion with limited resources.

    When does your instructor say this assignment is due?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    Probably followed this one...

    Please note the Forum Rules

    4. No homework questions

  4. #4
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6
    Hi,

    No this not HW and second i try many times and then i posted here to get a help and that is my try to solve it:

    grep -c | sort -u test.txt | tr -d "\t \v \f [unct:] [:upper:] "

    but actually i don't know how i can sort this commands ??

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Why are you restricted to using tr, sort, grep, and wc?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  6. #6
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6
    Because just this commands i can work with them clearly and plus ther is many references i found it on the net explain how i can used, so now i know how i can use this commands but i don't know how i can combine them.

  7. #7
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    Quote Originally Posted by Net-Man View Post
    I'm looking to write a sample shell script that counts the number of distinct words in a text file given as Argument.
    Remark: White space characters are spaces, tabs, form feeds, and new lines.

    JUST with this commands tr, sort, grep. wc.

    Thanks.
    Sounds to me like all you need is wc. Take the file you get in the command line and run it through that.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  8. #8
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6
    I will try thank you techieMoe

  9. #9
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Quote Originally Posted by techieMoe View Post
    Sounds to me like all you need is wc. Take the file you get in the command line and run it through that.
    Depends on what he means by "distinct".

Posting Permissions

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