Problem with grep caused me to spot library issue

dave261266

Registered
Hi Guys,

Being a Unix SA I drop to the command line a fair bit on my MAC. The other day I was trying to use grep to grab some stuff from a text file and I got the following message.

admin-accounts-imac:~ Dave$ grep http /tmp/dm
dyld: Library not loaded: /usr/lib/libpcre.0.dylib
Referenced from: /usr/bin/grep
Reason: no suitable image found. Did find:
/usr/lib/libpcre.0.dylib: open() failed with errno=13
/usr/lib/libpcre.0.dylib: open() failed with errno=13
Trace/BPT trap

thought initially it might be a corrput version of grep so I tried egrep and fgrep with the same result.

After a bit of digging I noticed that the library in question looked a little strange. Instead of being a binary file full of code it was actually a character special device.

c--------- 1 1979737344 1660971264 97, 0x00006800 1 Jan 1970 libpcre.0.0.1.dylib

Timestamp seemed strange too but I have no idea how this happenned. I checked another mac and found that the library in question should not actually be a character special file and as a workaround I have copied the library from another machine which seems to have rectifed the problem.

My question really is, has anyone seen this kind of behaviour before, does it occassionally happen after upgrades or something like that ?

Many Thanks

Dave
 
Sorry I cannot help, but one notion: In OS X and Linux, grep, egrep and fgrep are same program. You can check it with

$ ls -i /usr/bin/grep /usr/bin/egrep /usr/bin/fgrep

, you should get same number along the file names. This means that the program decides its behavior from the name (grep is the "old" grep, fgrep is grep without regular expressions and egrep is grep with expanded regular expressions).

I googled about the library. It is Perl compatible regular expression library. This is good news and bad news. Good is that it is not used by lots of the OS X programs. Bad news is that Safari seems to use it.
 
Back
Top