OT: presence of strings and grep on other OSes

Peter plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Fri Sep 16 16:24:10 UTC 2005


On Fri, 16 Sep 2005, Lennart Sorensen wrote:

> On Fri, Sep 16, 2005 at 11:00:13AM -0400, Byron L. Sonne wrote:
>> Not sure where else to turn, so I thought I'd ask you folks. I'm looking
>> to dig up information about how much I can rely on the presence of
>> strings and grep being present on some of the other unices out there,
>> such as AIX, HPUX, DGUX, etc. Older versions too. In some cases, egrep
>> is present and grep is not.
>
> I know I encountered an old slackware install a few years ago where grep
> didn't support -r which I found rather frustrating.  Other systems would
> most likely not be using gnu grep, although sometimes you get lucky (at
> least on solaris since many solaris admins hate the sun tools and prefer
> the gnu tools, and they want a compiler).
>
> I would think all unixes have grep although probably nowhere near as
> featureful as gnu grep.  strings I have no idea about.

grep -r and other features are gnu extensions. It says so in the 
manpage. Also all gnu tools have a 'compatibility' switch that makes 
them run in the way their 'ancestor' did. See grep -s, -w, -u, -b, 
POSIXLY_CORRECT, awk has --compat, --posix etc etc. There exist 
migration guides for this.

I have a gem of a book called 'POSIX Programmer's Guide' by Donald 
Lewine (O'Reilly) which explains all the details wrt writing portable 
*nix programs. There must be a similar book for shelland compatibility.

I find that by using only basic features (e.g. grep -v/-l/-e, simple awk 
programs etc) and assuming the shell /bin/sh (and not bash) is available 
I can write scripts than work on most machines (even on Solaris and 
*BSD). So far every time I used more advanced gnu extensions I 
eventually had to rewrite the script.

Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list