Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    2

    Unhappy Unanswered: Find command and problem with the result

    Hi

    I have to search in files and I think that the command "find" shuld be nice. I has tried this:

    find . -name *.doc -exec antiword {} \; | grep "a|b|c"

    and result of this would be
    a
    b
    c

    but I will alsol have which file has the information ? What do I have wrong ??'

    // Ronny

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Try:
    Code:
    egrep "a|b|c" *.doc


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jul 2006
    Posts
    2

    No it doesnt work

    I wrote the command wrong, it shuld be like this

    find . -name "*.doc" -exec antiword {} \; | grep "a|b|c"

    The answer you have doesnt make any diffrent. If you can see I have a pipe before grep so it takes the input to the grep command. Any other solution in this problem ????

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Thumbs up



    1) You want grep to look for the string 'a|b|c'? or 'a' or 'b' or 'c'?

    2) You want to know in which file it found it?

    You cannot know the source file unless the "antiword" script (program) returns it.


    -- OR --
    write an intermediate script like this:
    Code:
    #!/bin/ksh
    # MyWord.ksh - Script to call 'antiword'
    ret="`antiword $1`"
    [ ! -z $ret ] && echo "$1:$ret"
    exit
    and call like this:
    Code:
    find . -name *.doc -exec MyWord {} \; | grep "a|b|c" | tr "|" "\n"




    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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