LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Odd Behavior with fgrep: Slackware 14.1 64-bit (http://www.linuxquestions.org/questions/slackware-14/odd-behavior-with-fgrep-slackware-14-1-64-bit-4175486822/)

tronayne 12-04-2013 09:20 AM

Odd Behavior with fgrep: Slackware 14.1 64-bit
 
Doing a lot of fiddling and twiddling with PostgreSQL and Apache-Tomcat (building DSpace from scratch which requires Apache-Ant and Apache-Maven in addition). A few stops and starts of the DBMS and Tomcat.

I've been seeing nothing returned from
Code:

ps -ef | fgrep post
<and/or>
ps -ef | fgrep tom

when I know one or both is running.

I use fgrep out of long (really long) habit -- used to be you didn't have a lot of horsepower or memory and fgrep (fast grep) didn't load all of grep for a quick and dirty. Got in the habit and just keep on doing it, good, bad or indifferent. Hangover from System 3 and SVR4, I suppose.

Anyway, this isn't just one time, it's a bunch of times. Close the terminal, open a new terminal, exit Xfce, execute the command in console, log out, log back in, run it in console, startx and run it in a terminal, no joy.

Then, for whatever reason, the command works.

I dunno why (either does or doesn't); I'm not fumble-fingering, I'm not bumping a Ctrtl or Alt key and it's a keyboard, not a finger pad.

Tiz a puzzlement -- any ideas (other than well, quit using fgrep, stupid)?

syg00 12-04-2013 03:02 PM

I don't think I've ever used fgrep - until some testing just now. I also see inconsistent results.
Unless you plan to spend some time in (for example) strace output, I'd reckon your final idea is the best bet.

allend 12-04-2013 04:13 PM

Perhaps 'pgrep -l post' or pgrep -l tom' would satisfy your needs?

tronayne 12-05-2013 10:10 AM

Glad to know it's not "just me." fgrep is a base utility included in Unix and Linux systems since like forever; ought to work properly. I've got some time today to dig and see what, if anything, I can find. Nothing worse that intermittent...

The man page says that direct invocation of egrep or fgrep are deprecated (dammit), "but is provided to allow historical applications that rely on them to run unmodified." Oh, yeah? Well, I'm an historical application and I do rely on them even if I am a little (well, a lot) deprecated too..

A little looking around shows three different sizes for the "grep family:"
Code:

-rwxr-xr-x 1 root root 140632 Sep  4  2012 /bin/egrep*
-rwxr-xr-x 1 root root 104120 Sep  4  2012 /bin/fgrep*
-rwxr-xr-x 1 root root 343464 Sep  4  2012 /bin/grep*

and it could be that egrep and fgrep are just launchers that invoke grep with grep -E and grep -F. In any case, though, there's something not quite right.

If I remember correctly, egrep and fgrep are just striped down versions of grep, the idea being that you don't need all of grep's capabilities for a quick-'n'-dirty pattern match (back when you were running on 64K of RAM and a 50MB disk drive that mattered).

Reading back, I just noticed the date stamps on the executables -- 2012? Maybe a rebuild with the 14.1 libraries is in order? Hmm.

Time to dig.

55020 12-05-2013 10:27 AM

I use fgrep all the time, for the same reason as you -- ancient habit. (btw, I vaguely remember seeing someone purporting to show that modern grep is faster than fgrep, though that didn't get me out of the fgrep habit).

Anyway, fwiw, I've not noticed fgrep disgracing itself lately (or ever), but you've certainly got me on the lookout.

gnashley 12-05-2013 12:53 PM

IIRC, on slackware fgrep and egrep are wrappers to grep. fgrep as a separate program is still included in the sources and I install and use it as it is a bit faster than the full grep. Recently, after a long search I found a tiny, but full-featured grep implementation, but alas, it is slower than the full grep...

tronayne 12-05-2013 04:56 PM

Well, I don't know about the wrapper part (except for the POSIX shell scripts listed below?). The "grep" programs all seem to be binary:
Code:

file /bin/grep*
/bin/grep: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
fubar-trona-/home/trona: file /bin/*grep
/bin/egrep:  ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
/bin/fgrep:  ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
/bin/grep:  ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
/bin/zegrep: POSIX shell script, ASCII text executable
/bin/zfgrep: POSIX shell script, ASCII text executable
/bin/zgrep:  POSIX shell script, ASCII text executable

and all have sizes as listed in the post above.

Maybe they're fork-and-exec'd? Don't think so, 'cause they'd be the same size as grep if it's one of those "the command you provided makes it look like something else" thing (like vi used to be when it was really ex you were executing in "visual mode."

Like I said, a puzzlement.


All times are GMT -5. The time now is 05:12 PM.