• Re: how to capture only 7 or 8 in /etc/redhat-release

    From Neeraj Kumar@21:1/5 to Chris Elvidge on Mon Jun 5 06:14:07 2023
    On Monday, June 5, 2023 at 6:19:02 PM UTC+5:30, Chris Elvidge wrote:
    On 05/06/2023 13:23, Neeraj Kumar wrote:
    I have two version; please help me to get the version in the form of 7 or 8

    grep -o -E "7|8" /etc/redhat-release

    --
    Chris Elvidge
    England

    Thank you for the reply..
    if the Linux is 8.7 then it will not give proper output.

    can we have this by awk command .. I tried multiple but unlucky to get in single line

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Neeraj Kumar@21:1/5 to All on Mon Jun 5 05:23:27 2023
    I have two version; please help me to get the version in the form of 7 or 8

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Elvidge@21:1/5 to Neeraj Kumar on Mon Jun 5 13:48:56 2023
    On 05/06/2023 13:23, Neeraj Kumar wrote:
    I have two version; please help me to get the version in the form of 7 or 8


    grep -o -E "7|8" /etc/redhat-release

    --
    Chris Elvidge
    England

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Chris Elvidge on Mon Jun 5 14:36:27 2023
    Chris Elvidge <[email protected]> writes:

    On 05/06/2023 13:23, Neeraj Kumar wrote:
    I have two version; please help me to get the version in the form of 7 or 8 >>

    grep -o -E "7|8" /etc/redhat-release

    This will say 7 for release 6.7 (not that I know there ever was such a
    release number) but even given the OPs restriction to 7 or 8, version
    7.8 will give two lines.

    One way (if one's grep has them) would be to use Perl REs and employ a "lookbehind" assertion:

    grep -o -P '(?<=release )\d+' /etc/redhat-release

    but then it's not at all clear what OP really wants.

    To the OP: it's generally better to look in /etc/os-release.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Neeraj Kumar on Mon Jun 5 15:55:43 2023
    On 05.06.2023 15:14, Neeraj Kumar wrote:
    On Monday, June 5, 2023 at 6:19:02 PM UTC+5:30, Chris Elvidge wrote:
    On 05/06/2023 13:23, Neeraj Kumar wrote:
    I have two version; please help me to get the version in the form of 7 or 8 >>>
    grep -o -E "7|8" /etc/redhat-release

    --
    Chris Elvidge
    England

    Thank you for the reply..
    if the Linux is 8.7 then it will not give proper output.

    You could use sed for the extraction of the number

    echo " 8.7 "| sed 's/.*\([78]\)[.].*/\1/'

    or shell's expr

    expr " 8.7 " : '.*\([78]\)[.].*'

    (In both cases taking the digit 7 or 8 in front of a literal dot.)


    can we have this by awk command .. I tried multiple but unlucky to get in single line

    Why awk?

    With Ben's suggestion for the source of the version information

    awk -F[=\".] '/VERSION=/{print $3}' /etc/os-release

    (can of course also done with sed or shell in a most simple way).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Janis Papanagnou on Mon Jun 5 15:57:24 2023
    On 05.06.2023 15:55, Janis Papanagnou wrote:

    or shell's expr

    Erm.. - it's not a shell built-in but an ordinary command.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Neeraj Kumar on Mon Jun 5 16:29:10 2023
    On 2023-06-05, Neeraj Kumar <[email protected]> wrote:
    On Monday, June 5, 2023 at 6:19:02 PM UTC+5:30, Chris Elvidge wrote:
    On 05/06/2023 13:23, Neeraj Kumar wrote:
    I have two version; please help me to get the version in the form of 7 or 8

    grep -o -E "7|8" /etc/redhat-release

    --
    Chris Elvidge
    England

    Thank you for the reply..
    if the Linux is 8.7 then it will not give proper output.

    If Linux is 8.7, today can't be 2023. The current stable version is
    6.3.6, with a 6.4-rc5 (release candidate 5) on the mainline.

    See https://kernel.org


    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @[email protected]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David W. Hodgins@21:1/5 to Neeraj Kumar on Mon Jun 5 12:28:27 2023
    On Mon, 05 Jun 2023 08:23:27 -0400, Neeraj Kumar <[email protected]> wrote:

    I have two version; please help me to get the version in the form of 7 or 8

    Why use /etc/redhat-release? /etc/lsb-release is more likely to be found in various distributions, and is easier to parse in bash.

    $ . /etc/lsb-release
    $ echo $DISTRIB_RELEASE
    8
    $ echo $DISTRIB_ID
    Mageia

    Regards, Dave Hodgins

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Kaz Kylheku on Mon Jun 5 10:33:07 2023
    Kaz Kylheku <[email protected]> writes:
    On 2023-06-05, Neeraj Kumar <[email protected]> wrote:
    [...]
    if the Linux is 8.7 then it will not give proper output.

    If Linux is 8.7, today can't be 2023. The current stable version is
    6.3.6, with a 6.4-rc5 (release candidate 5) on the mainline.

    See https://kernel.org

    Kaz's point is that Linux (the kernel) and Red Hat (the operating
    system) are two different things with different version numbers. /etc/redhat-release has information about the OS.

    --
    Keith Thompson (The_Other_Keith) [email protected]
    Will write code for food.
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bit Twister@21:1/5 to David W. Hodgins on Mon Jun 5 12:15:06 2023
    On Mon, 05 Jun 2023 12:28:27 -0400, David W. Hodgins wrote:
    On Mon, 05 Jun 2023 08:23:27 -0400, Neeraj Kumar <[email protected]> wrote:

    I have two version; please help me to get the version in the form of 7 or 8

    Why use /etc/redhat-release? /etc/lsb-release is more likely to be found in various distributions, and is easier to parse in bash.

    $ . /etc/lsb-release
    $ echo $DISTRIB_RELEASE
    8
    $ echo $DISTRIB_ID
    Mageia

    Regards, Dave Hodgins

    Or the op could do something like
    $ . /etc/os-release
    $ echo $VERSION
    or
    $ echo $VERSION_ID

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Neeraj Kumar on Mon Jun 5 10:30:56 2023
    Neeraj Kumar <[email protected]> writes:
    I have two version; please help me to get the version in the form of 7 or 8

    Please show us the content of /etc/redhat-release.

    --
    Keith Thompson (The_Other_Keith) [email protected]
    Will write code for food.
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Keith Thompson on Mon Jun 5 18:56:43 2023
    On 2023-06-05, Keith Thompson <[email protected]> wrote:
    Kaz Kylheku <[email protected]> writes:
    On 2023-06-05, Neeraj Kumar <[email protected]> wrote:
    [...]
    if the Linux is 8.7 then it will not give proper output.

    If Linux is 8.7, today can't be 2023. The current stable version is
    6.3.6, with a 6.4-rc5 (release candidate 5) on the mainline.

    See https://kernel.org

    Kaz's point is that Linux (the kernel) and Red Hat (the operating
    system) are two different things with different version numbers. /etc/redhat-release has information about the OS.

    Unlike some, I don't have a problem with Red Hat being called a
    "Linux distribution", but when you start talking about it it being
    Linux 8.7, we have crossed the blurry line between political
    and stupid.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @[email protected]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Kaz Kylheku on Mon Jun 5 13:16:26 2023
    Kaz Kylheku <[email protected]> writes:
    On 2023-06-05, Keith Thompson <[email protected]> wrote:
    Kaz Kylheku <[email protected]> writes:
    On 2023-06-05, Neeraj Kumar <[email protected]> wrote:
    [...]
    if the Linux is 8.7 then it will not give proper output.

    If Linux is 8.7, today can't be 2023. The current stable version is
    6.3.6, with a 6.4-rc5 (release candidate 5) on the mainline.

    See https://kernel.org

    Kaz's point is that Linux (the kernel) and Red Hat (the operating
    system) are two different things with different version numbers.
    /etc/redhat-release has information about the OS.

    Unlike some, I don't have a problem with Red Hat being called a
    "Linux distribution", but when you start talking about it it being
    Linux 8.7, we have crossed the blurry line between political
    and stupid.

    My point was not about the politics of referring to a distribution as
    "Linux". My point was that the person you were addressing might not
    have understood what you were talking about.

    Neeraj wrote something incorrect. That doesn't imply they're stupid.

    --
    Keith Thompson (The_Other_Keith) [email protected]
    Will write code for food.
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Harnden@21:1/5 to Keith Thompson on Tue Jun 6 11:50:53 2023
    On 05/06/2023 18:30, Keith Thompson wrote:
    Neeraj Kumar <[email protected]> writes:
    I have two version; please help me to get the version in the form of 7 or 8

    Please show us the content of /etc/redhat-release.


    This is what I have. They dropped 'Server' for version 8 ...

    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
    Red Hat Enterprise Linux Server release 5.11 (Tikanga)
    Red Hat Enterprise Linux Server release 6.4 (Santiago)
    Red Hat Enterprise Linux Server release 6.6 (Santiago)
    Red Hat Enterprise Linux Server release 6.7 (Santiago)
    Red Hat Enterprise Linux Server release 6.8 (Santiago)
    Red Hat Enterprise Linux Server release 6.9 (Santiago)
    Red Hat Enterprise Linux Server release 6.10 (Santiago)
    Red Hat Enterprise Linux Server release 7.4 (Maipo)
    Red Hat Enterprise Linux Server release 7.6 (Maipo)
    Red Hat Enterprise Linux Server release 7.7 (Maipo)
    Red Hat Enterprise Linux Server release 7.9 (Maipo)
    Red Hat Enterprise Linux release 8.1 (Ootpa)
    Red Hat Enterprise Linux release 8.3 (Ootpa)
    Red Hat Enterprise Linux release 8.4 (Ootpa)
    Red Hat Enterprise Linux release 8.6 (Ootpa)

    Also, CentOs ...

    CentOS Linux release 7.9.2009 (Core)
    CentOS Stream release 8

    /etc/os-release doesn't seem to exist prior to version 7, and CentOs
    Stream dropped the decimal-point - but VERSION_ID is the easiest to parse.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Richard Harnden on Tue Jun 6 11:35:26 2023
    Richard Harnden <[email protected]> writes:
    On 05/06/2023 18:30, Keith Thompson wrote:
    Neeraj Kumar <[email protected]> writes:
    I have two version; please help me to get the version in the form of 7 or 8 >> Please show us the content of /etc/redhat-release.


    This is what I have. They dropped 'Server' for version 8 ...

    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
    [SNIP]
    Red Hat Enterprise Linux release 8.4 (Ootpa)
    Red Hat Enterprise Linux release 8.6 (Ootpa)

    Also, CentOs ...

    CentOS Linux release 7.9.2009 (Core)
    CentOS Stream release 8

    /etc/os-release doesn't seem to exist prior to version 7, and CentOs
    Stream dropped the decimal-point - but VERSION_ID is the easiest to
    parse.

    Is /etc/redhat-release always just one line? (Similar files like /etc/lsb-release are several lines.)

    --
    Keith Thompson (The_Other_Keith) [email protected]
    Will write code for food.
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Harnden@21:1/5 to Keith Thompson on Tue Jun 6 19:55:44 2023
    On 06/06/2023 19:35, Keith Thompson wrote:
    Richard Harnden <[email protected]> writes:
    On 05/06/2023 18:30, Keith Thompson wrote:
    Neeraj Kumar <[email protected]> writes:
    I have two version; please help me to get the version in the form of 7 or 8
    Please show us the content of /etc/redhat-release.


    This is what I have. They dropped 'Server' for version 8 ...

    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
    [SNIP]
    Red Hat Enterprise Linux release 8.4 (Ootpa)
    Red Hat Enterprise Linux release 8.6 (Ootpa)

    Also, CentOs ...

    CentOS Linux release 7.9.2009 (Core)
    CentOS Stream release 8

    /etc/os-release doesn't seem to exist prior to version 7, and CentOs
    Stream dropped the decimal-point - but VERSION_ID is the easiest to
    parse.

    Is /etc/redhat-release always just one line? (Similar files like /etc/lsb-release are several lines.)


    Yes, it's always one line.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pyt T.@21:1/5 to Richard Harnden on Wed Jun 7 07:25:47 2023
    On Tue, 6 Jun 2023 11:50:53 +0100, Richard Harnden <[email protected]> wrote:
    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
    Red Hat Enterprise Linux Server release 5.11 (Tikanga)
    Red Hat Enterprise Linux Server release 6.4 (Santiago)
    Red Hat Enterprise Linux Server release 6.6 (Santiago)
    Red Hat Enterprise Linux Server release 6.7 (Santiago)
    Red Hat Enterprise Linux Server release 6.8 (Santiago)
    Red Hat Enterprise Linux Server release 6.9 (Santiago)
    Red Hat Enterprise Linux Server release 6.10 (Santiago)
    Red Hat Enterprise Linux Server release 7.4 (Maipo)
    Red Hat Enterprise Linux Server release 7.6 (Maipo)
    Red Hat Enterprise Linux Server release 7.7 (Maipo)
    Red Hat Enterprise Linux Server release 7.9 (Maipo)
    Red Hat Enterprise Linux release 8.1 (Ootpa)
    Red Hat Enterprise Linux release 8.3 (Ootpa)
    Red Hat Enterprise Linux release 8.4 (Ootpa)
    Red Hat Enterprise Linux release 8.6 (Ootpa)

    If I parse this list through:
    sed 's/.*release \([^(]*\)(.*/\1/'

    I get:
    5.6
    5.8
    5.11
    6.4
    6.6
    6.7
    6.8
    6.9
    6.10
    7.4
    7.6
    7.7
    7.9
    8.1
    8.3
    8.4
    8.6

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pyt T.@21:1/5 to Pyt T. on Wed Jun 7 07:33:59 2023
    On Wed, 7 Jun 2023 07:25:47 -0000 (UTC), Pyt T. <[email protected]> wrote:
    On Tue, 6 Jun 2023 11:50:53 +0100, Richard Harnden <[email protected]> wrote:
    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
    Red Hat Enterprise Linux Server release 5.11 (Tikanga)
    Red Hat Enterprise Linux Server release 6.4 (Santiago)
    Red Hat Enterprise Linux Server release 6.6 (Santiago)
    Red Hat Enterprise Linux Server release 6.7 (Santiago)
    Red Hat Enterprise Linux Server release 6.8 (Santiago)
    Red Hat Enterprise Linux Server release 6.9 (Santiago)
    Red Hat Enterprise Linux Server release 6.10 (Santiago)
    Red Hat Enterprise Linux Server release 7.4 (Maipo)
    Red Hat Enterprise Linux Server release 7.6 (Maipo)
    Red Hat Enterprise Linux Server release 7.7 (Maipo)
    Red Hat Enterprise Linux Server release 7.9 (Maipo)
    Red Hat Enterprise Linux release 8.1 (Ootpa)
    Red Hat Enterprise Linux release 8.3 (Ootpa)
    Red Hat Enterprise Linux release 8.4 (Ootpa)
    Red Hat Enterprise Linux release 8.6 (Ootpa)

    If I parse this list through:
    sed 's/.*release \([^(]*\)(.*/\1/'

    I get:
    5.6
    5.8
    5.11
    6.4
    6.6
    6.7
    6.8
    6.9
    6.10
    7.4
    7.6
    7.7
    7.9
    8.1
    8.3
    8.4
    8.6

    Use:
    sed 's/.*\([0-9]\)\..*/\1/'

    to get:
    5
    5
    5
    6
    6
    6
    6
    6
    6
    7
    7
    7
    7
    8
    8
    8
    8

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cyrille Lefevre@21:1/5 to All on Fri Mar 29 03:10:11 2024
    Le Mon, 5 Jun 2023 05:23:27 -0700 (PDT), Neeraj Kumar <[email protected]> a �crit :

    I have two version; please help me to get the version in the form of 7 or 8

    osver=$(tr -cd 0-9 < /etc/redhat-release)
    minor=%${osver#?}
    major=${osver%${osver#?}}

    Regards
    --
    mailto:Cyrille.Lefevre-news%[email protected]d
    remove "%nospam" and ".invalid" to answer me.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)