Solved

looking for rgrep port for Solaris (from Linux)

Posted on 2000-03-29
15
378 Views
Last Modified: 2013-12-20
I know that Linux offers an rgrep command and want Solaris binaries. I *do* not want an RPM, please, because I don't have all of the dependancies. Nor do I want (yet another) Perl scrip, fine as they are.

The points will only go to someone who has taken the Linux sources to rgrep & recompiled them under Solais. I'd like a single executable (if possible). Sources might be a bonus too.

Anyone out there done it already?
0
Comment
Question by:graham_k
  • 8
  • 7
15 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2667568
Is there some reason that you can't use the recursive option of gnu grep? The only time I compared rgrep and "grep -r" it seemed to me that grep was faster. There's a precompiled grep-2.0 in the Solaris 2.5 collection on http://sunfreeware.com/ that will run on 2.5 and later.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2667680
thanks very much for the suggestion. Unfortunately, it didn't work out.

As I said, I can't install packages. So, I D/Led the sources & built. Unfortunately, grep2.0 doesn't support a -r option.

Any other ideas?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2667710
Oh, If you can build sources go to http://www.gnu.org/order/ftp.html and pick a mirror site close to you and download the latest version (grep-2.4.2). From your question I thought you only could use a binary and I didn't realize that the recursive option isn't in 2.0. That's my mistake, and I apologise for it.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2667916
o.k, I found the source of grep 2.3 and that supports a -r option. I guess that I will use that.

Thanks for trying anayway.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2667920
This question has a deletion request Pending
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2667964
This question no longer is pending deletion
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2667965
2.3 had some bugs and performance problems, you'd be better off with 2.4.2.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Author Comment

by:graham_k
ID: 2668247
sounds good, do you know where I can lay my hands on the source code?
0
 
LVL 6

Author Comment

by:graham_k
ID: 2668315
o.k, found it (by searching on http://www.gnu.org).

I found v2.4, if you know where the source for v2.4.2 is, let me know.

I'd still quite like the Linux rgrep as that coulour highlights the matched string. If I weren't too lazy, I'd hack this code myself to do it.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2668343
btw, a totally stupid question, but why doesn't

grep ifdef *.c

produce the expected result ? I'm forced to

grep ifdef *

which of course slows it down & greps through binaries, etc.

Am I missing something blindingly obvious?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2669272
As to 2.4.2, I just went to  http://www.gnu.org/order/ftp.html, from an earlier comment, picked the closest mirror (ftp://ftp.uu.net/archive/systems/gnu/ in my case) and then looked in the grep subdir.

"grep ifdef *.c" certainly should look at all .c files in a directory, it does for me. It's the shell's job to expand the wildcard (*.c), grep just processes each of the file names. What do you see if you got to that dir and do "ls *.c"?
0
 
LVL 6

Author Comment

by:graham_k
ID: 2671708
well, as the only respondant, you're going to get the point anyway.  I don't like to sound like I'm trying to get an extra question answered for free here, but I just can't get the resursive part to work, which is the whole point of the exercise.

When in my source directory
      grep ifdef *.c
works just fine. Making it recusrive
      grep -r ifdef *.c
also works (although it' spointless, since there are no subdirectories). BUT, if I cd .. and issue the same command, I get  "No match.". This has got me stumped. The same result (obviously) when I replace -r with its functional equivelant --directories=recurse.

Am I missing something obvious?
0
 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
ID: 2671846
While I do love to "get the points", the biggest reason that I participate is to help people solve problems. And, as you correctly pointed out, the whole point of the exercise is to do recursive greps, so it isn't a case of getting a second answer for free in my opionion.

The recursive option for grep takes a directory as the argument, not a file pattern. Thus, "grep -r ulong /usr/include" will search all files in the /usr/include tree. As you've noted about some of the other methods, that isn't exactly efficient as it'll examine all files. A frequently used method of limiting grep to only one class of files is to use find. For example, find some-dir -name "*.c" -exec grep gettimeofday {} \;" will descend into some-dir (which can be . for the current dir), passing each ".c" file encounterd to grep for examination. Not as convient as rgrep, but workable.

This evening I found sources to rgrep. I can't get the site that's supposedly the home to respond (looks like a router problem). But I did find a src rpm that looks to be current. I haven't yet had time to try building it. Since you are on a Solaris box, the src rpm won't be of just a whole lot of use. I don't see a good way to pass it in one of these commnets, but if you'll drop an email to jlevie@bellsouth.net, I'll send you what I've found. BTW, the reason the sources are hard to find is that they are a part of the jed editor, go figure...
0
 
LVL 6

Author Comment

by:graham_k
ID: 2671888
Aha! so "grep -r ifdef ." works. Wonderful!

I've played with various permutations of piping the output of find to grep. About a year ago I went heavilly into research mode on this. There were all sorts of Un*x guru flame wars on UseNet, about starting a new shell for each file found, use of xargs, etc. I can't remember it all. I also didn't fancy remembering & typing in a complex command every time I needed it. Strangely, what works on the command line, does not work from within a shell script. Also, I couldn't figure out how to set up an alias for the command. I did find some useful Perl scripts, but I reckoned that the best way has to be one dedicated binary.


yes, I found those Jed sources too, but couldn't get them to build. I can't remember why. Missing some includes, I think. I'll drop you a mail, in case you have any success.

At least now that you explained that the file parameter becomes a driectory, I _can_ do what I wanted to do. So I will award you the points. No need to stop posting, though :-)

Thanks again.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2671907
Okay... I'll take a crack at getting it to compile tomorrow.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now