How can I check the version of sed in OS X?

后端 未结 2 834
野性不改
野性不改 2020-11-30 09:54

I know if sed is GNU version, version check can be done like

$ sed --version

But this doesn\'t work in OS X. How can I do that

2条回答
  •  失恋的感觉
    2020-11-30 10:21

    Looking though the various version of sed in text_cmds there are not many changes.

    • 10.0.0 Used NetBSD sed from fall 1998
    • 10.3.0 Used FreeBSD sed from fall 2002 but left the man-page unchanged, adding -E extended regular expressions and -i in-place editing.
    • 10.4.0 Had some fixes for in-place editing, and changed the man-page to the FreeBSD man-page from fall 2004.
    • 10.5.0 Updated to FreeBSD sed from fall 2005, adding -l line-buffered output and more refinements/fixes to in-place editing.
    • 10.6.0 Added a reference to compat(5) in the man-page.

    The version of the operating-system can be checked, instead of the sed utility, by either using uname -r or sw_vers -productversion:

    case $(sw_vers -productversion) in
    10.[012].*)     echo no in-place editig, EREs, or line-buffered output;;
    10.[45].*)      echo no line-buffered output;;
    10.[6789].*)    echo newest version as of writing;;
    10.1[01].*)     echo newest version as of writing;;
    esac
    

    (BSD utilities are not versioned because they are considered part of their operating-system)

提交回复
热议问题