Skip to main content
3 of 10
added 117 characters in body
Sildoreth
  • 2k
  • 8
  • 25
  • 42

When to use XPG* version of a command?

I occasionally do work on an older Solaris machine whose version of grep is incomplete. This causes problems in my rc files because the default grep on the machine doesn't support the options I need.

This is a machine at work, so I can't just install newer/better versions of commands as I see fit. However, I notice that the machine does have a suitable version of grep in /usr/xpg4/bin/grep.

Obviously, I can solve the problem in my rc files with:

alias grep='/usr/xpg4/bin/grep'

But what about machines where this isn't necessary? My goal is to have a single rc file for each shell that I can drop into any Unix-like system and have it just work.

This got me thinking...

  1. Is there ever a case where I wouldn't want to use the XPG version of a command?
    • If so, when?
  2. Couldn't I just blindly add /usr/xpg4/bin/ to the beginning of $PATH in my rc files on all machines and forgo aliasing individual commands to their XPG* versions?
    • Or will this cause problems for some commands?
  3. Is it the case that /usr/xpg4/bin/ exists only on machines where it is "necessary"?
    • I ask because I notice that /usr/xpg4/bin/ doesn't exist on my Ubuntu machine.
Sildoreth
  • 2k
  • 8
  • 25
  • 42