If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Find command and problem with the result

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-06, 03:26
ronst ronst is offline
Registered User
 
Join Date: Jul 2006
Posts: 2
Unhappy 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
Reply With Quote
  #2 (permalink)  
Old 07-07-06, 09:16
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
  #3 (permalink)  
Old 07-10-06, 03:13
ronst ronst is offline
Registered User
 
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 ????
Reply With Quote
  #4 (permalink)  
Old 07-11-06, 12:53
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On