What is the difference between xpg4/bin and usr/bin?

Hi Experts,

I found that the same commands(sort, du, df, find, grep etc.) exists in both dir.

What is the difference to use them?

i.e: to use

xpg4/bin/grep

and

usr/bin/grep

My OS version is SunOS 5.10

Regards,
Saps

Those are different variants of grep. Check man grep for differences between them.

I checked, that means usr/xpg4/bin/<commands> are more advanced(or say, more powerful) than usr/bin/<commands>.

Please correct me if I understood it wrong.

Yes, it is true in most of the cases.

1 Like

More precisely they provide variants of commands complying with different standards:

/usr/bin: SVID/XPG3
/usr/xpg4/bin: POSIX.2/POSIX.2a/SUS/SUSv2/XPG4
/usr/xpg6/bin: POSIX.1-2001/SUSv3

Standard compliance doesn't necessarily means the commands are more or less powerful, just they have slight differences in their options and behavior.

2 Likes

Thank you, I have just the following query:
If we use simply grep <file_name> or find <path> -name <search_string>, in those cases which commands will execute by default? usr/bin<commnads> or usr/xpg4/bin/<commnads>?

It depends on which path you have defined first in you $PATH variable. Check it in the output of

echo $PATH

I think it uses usr/bin.

@saps$> echo $PATH
/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/bin:/usr/openwin/bin:/usr/bin:/usr/ccs/bin:/usr/local/bin