• The last blank line can be removed by sed.

    From [email protected]@21:1/5 to All on Tue Jan 10 00:32:01 2023
    See my following 2 testings:

    Testing 1:

    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g;/^$/d' | tail | cat -A
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    $
    werner@X10DAi:~$

    Testing 2:
    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d' | tail | cat -A
    znchartoprimitive$
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    werner@X10DAi:~$

    As you can see, if I combine the above two sed commands into a single sed
    call, the last line will be blank in the output, as shown in the testing 1.

    Is there any explanation for this behavior?

    Regards,
    Zhao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to [email protected] on Tue Jan 10 13:36:26 2023
    On 10.01.2023 09:32, [email protected] wrote:
    See my following 2 testings:

    Testing 1:

    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g;/^$/d' | tail | cat -A
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    $
    werner@X10DAi:~$

    Testing 2:
    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d' | tail | cat -A
    znchartoprimitive$
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    werner@X10DAi:~$

    As you can see, if I combine the above two sed commands into a single sed call, the last line will be blank in the output, as shown in the testing 1.

    $ gp
    ksh: gp: not found [No such file or directory]

    (Why don't you provide a minimum working example as you've been
    suggested many times already?)


    Is there any explanation for this behavior?

    $ { seq 3 ; echo ;}
    1
    2
    3

    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g;/^$/d'
    1
    2
    3
    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d'
    1
    2
    3

    Works for me. (Same output.)

    BTW, what is -E supposed to do? (Use of EREs instead of BREs?)
    Option -E is not documented in my sed man page.

    (You may want to consider using awk instead of these grep/sed/...
    pipelines. As a side-effect that may also fix your issue.)

    Janis


    Regards,
    Zhao


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geoff Clare@21:1/5 to Janis Papanagnou on Tue Jan 10 13:40:44 2023
    Janis Papanagnou wrote:

    On 10.01.2023 09:32, [email protected] wrote:

    As you can see, if I combine the above two sed commands into a single sed
    call, the last line will be blank in the output, as shown in the testing 1. >>
    Is there any explanation for this behavior?

    REs are matched against the "pattern space", not individual lines
    within the pattern space. Normally the pattern space only contains
    one line, but the substitution with a \n on the right hand side makes
    it contain multiple lines. Try this:

    sed -Ee 's/[ ]+/\n/g;s/\n$//'

    $ { seq 3 ; echo ;}
    1
    2
    3

    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g;/^$/d'
    1
    2
    3
    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d'
    1
    2
    3

    Works for me. (Same output.)

    That's because the input to sed didn't include any space characters.
    Try it with { seq 3 ; echo ' ' ;} | ...

    BTW, what is -E supposed to do? (Use of EREs instead of BREs?)

    You guessed right. It will be in the next version of POSIX.

    --
    Geoff Clare <[email protected]>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Janis Papanagnou on Tue Jan 10 06:23:35 2023
    On Tuesday, January 10, 2023 at 8:38:49 PM UTC+8, Janis Papanagnou wrote:
    On 10.01.2023 09:32, [email protected] wrote:
    See my following 2 testings:

    Testing 1:

    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g;/^$/d' | tail | cat -A
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    $
    werner@X10DAi:~$

    Testing 2:
    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d' | tail | cat -A
    znchartoprimitive$
    znconreychar$
    znconreyconductor$
    znconreyexp$
    znconreylog$
    zncoppersmith$
    znlog$
    znorder$
    znprimroot$
    znstar$
    werner@X10DAi:~$

    As you can see, if I combine the above two sed commands into a single sed call, the last line will be blank in the output, as shown in the testing 1.
    $ gp
    ksh: gp: not found [No such file or directory]

    gp is an easy-to-use interactive shell giving access to the PARI functions:

    https://pari.math.u-bordeaux.fr/

    (Why don't you provide a minimum working example as you've been
    suggested many times already?)

    I'm in a hurry and just think this is an open source software package, which is available in package repositories of various *nix systems.


    Is there any explanation for this behavior?
    $ { seq 3 ; echo ;}
    1
    2
    3

    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g;/^$/d'
    1
    2
    3
    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d'
    1
    2
    3

    Works for me. (Same output.)

    I also confirmed your statement with your above examples.

    BTW, what is -E supposed to do? (Use of EREs instead of BREs?)
    Option -E is not documented in my sed man page.

    werner@X10DAi:~$ sed --version |head -2
    sed (GNU sed) 4.8
    Packaged by Debian
    werner@X10DAi:~$ sed --help|grep -- -E
    -E, -r, --regexp-extended
    (for portability use POSIX -E).

    (You may want to consider using awk instead of these grep/sed/...
    pipelines. As a side-effect that may also fix your issue.)

    Janis


    Regards,
    Zhao


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Geoff Clare on Tue Jan 10 06:27:38 2023
    On Tuesday, January 10, 2023 at 9:41:10 PM UTC+8, Geoff Clare wrote:
    Janis Papanagnou wrote:

    On 10.01.2023 09:32, [email protected] wrote:

    As you can see, if I combine the above two sed commands into a single sed >> call, the last line will be blank in the output, as shown in the testing 1.

    Is there any explanation for this behavior?
    REs are matched against the "pattern space", not individual lines
    within the pattern space. Normally the pattern space only contains
    one line, but the substitution with a \n on the right hand side makes
    it contain multiple lines. Try this:

    sed -Ee 's/[ ]+/\n/g;s/\n$//'
    $ { seq 3 ; echo ;}
    1
    2
    3

    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g;/^$/d'
    1
    2
    3
    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d'
    1
    2
    3

    Works for me. (Same output.)
    That's because the input to sed didn't include any space characters.
    Try it with { seq 3 ; echo ' ' ;} | ...

    Yes. As shown below:

    werner@X10DAi:~$ { seq 3 ; echo ' ';} | sed -Ee 's/[ ]+/\n/g;/^$/d' | cat -A
    1$
    2$
    3$
    $
    $
    werner@X10DAi:~$ { seq 3 ; echo -n ' ';} | sed -Ee 's/[ ]+/\n/g;/^$/d' | cat -A 1$
    2$
    3$
    $
    werner@X10DAi:~$

    BTW, what is -E supposed to do? (Use of EREs instead of BREs?)
    You guessed right. It will be in the next version of POSIX.

    --
    Geoff Clare <[email protected]>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to [email protected] on Wed Jan 11 00:41:02 2023
    On Tuesday, January 10, 2023 at 10:27:41 PM UTC+8, [email protected] wrote:
    On Tuesday, January 10, 2023 at 9:41:10 PM UTC+8, Geoff Clare wrote:
    Janis Papanagnou wrote:

    On 10.01.2023 09:32, [email protected] wrote:

    As you can see, if I combine the above two sed commands into a single sed
    call, the last line will be blank in the output, as shown in the testing 1.

    Is there any explanation for this behavior?
    REs are matched against the "pattern space", not individual lines
    within the pattern space. Normally the pattern space only contains
    one line, but the substitution with a \n on the right hand side makes
    it contain multiple lines. Try this:

    sed -Ee 's/[ ]+/\n/g;s/\n$//'
    $ { seq 3 ; echo ;}
    1
    2
    3

    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g;/^$/d'
    1
    2
    3
    $ { seq 3 ; echo ;} | sed -Ee 's/[ ]+/\n/g' | sed -Ee '/^$/d'
    1
    2
    3

    Works for me. (Same output.)
    That's because the input to sed didn't include any space characters.
    Try it with { seq 3 ; echo ' ' ;} | ...
    Yes. As shown below:

    werner@X10DAi:~$ { seq 3 ; echo ' ';} | sed -Ee 's/[ ]+/\n/g;/^$/d' | cat -A 1$
    2$
    3$
    $
    $
    werner@X10DAi:~$ { seq 3 ; echo -n ' ';} | sed -Ee 's/[ ]+/\n/g;/^$/d' | cat -A
    1$
    2$
    3$
    $
    werner@X10DAi:~$
    BTW, what is -E supposed to do? (Use of EREs instead of BREs?)
    You guessed right. It will be in the next version of POSIX.

    --
    Geoff Clare <[email protected]>

    P.S. Based on the discussion here [1], the reason for the problem here is explained in the info of sed, but not in man:

    werner@X10DAi:~$ sed --version |head -3
    sed (GNU sed) 4.8
    Packaged by Debian
    Copyright (C) 2020 Free Software Foundation, Inc.

    werner@X10DAi:~$ info sed |grep -A5 -i 'In a substitution command'
    In a substitution command, the 'w' flag writes the substitution
    result to a file, and the 'e' flag executes the subsitution result
    as a shell command. As with the 'r/R/w/W/e' commands, these must
    be terminated with a newline. If whitespace, comments or
    semicolons are found, they will be included in the shell command or
    filename, leading to unexpected results:

    werner@X10DAi:~$ man sed |grep -i 'In a substitution command'

    werner@X10DAi:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 22.10
    Release: 22.10
    Codename: kinetic

    [1] http://pari.math.u-bordeaux.fr/archives/pari-users-2301/msg00049.html

    Best,
    Zhao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to [email protected] on Wed Jan 11 14:19:26 2023
    On Wed, 11 Jan 2023 00:41:02 -0800 (PST)
    "[email protected]" <[email protected]> wrote:
    On Tuesday, January 10, 2023 at 10:27:41 PM UTC+8, [email protected] wrote:
    On Tuesday, January 10, 2023 at 9:41:10 PM UTC+8, Geoff Clare wrote:
    Janis Papanagnou wrote:

    On 10.01.2023 09:32, [email protected] wrote:

    As you can see, if I combine the above two sed commands into a single sed
    call, the last line will be blank in the output, as shown in the testing 1.

    Is there any explanation for this behavior?
    REs are matched against the "pattern space", not individual lines
    within the pattern space. Normally the pattern space only contains
    one line, but the substitution with a \n on the right hand side makes
    it contain multiple lines. Try this:

    sed -Ee 's/[ ]+/\n/g;s/\n$//'

    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    Solution given.


    P.S. Based on the discussion here [1], the reason for the problem here
    is explained in the info of sed, but not in man:

    werner@X10DAi:~$ sed --version |head -3
    sed (GNU sed) 4.8
    Packaged by Debian
    Copyright (C) 2020 Free Software Foundation, Inc.

    werner@X10DAi:~$ info sed |grep -A5 -i 'In a substitution command'
    In a substitution command, the 'w' flag writes the substitution
    result to a file, and the 'e' flag executes the subsitution result
    as a shell command. As with the 'r/R/w/W/e' commands, these must
    be terminated with a newline. If whitespace, comments or
    semicolons are found, they will be included in the shell command or
    filename, leading to unexpected results:

    No , this quote is unrelated. The explanation for the beaviour you observed
    (I wouldn't call it a problem) is explained by Geoff above and he gives a solution too.

    [1] http://pari.math.u-bordeaux.fr/archives/pari-users-2301/msg00049.html

    --
    Forth is a strange combination of computer language and religion.
    Sol Guber at http://mirror.optus.com.au/pub/forth/Archive/docs/mforth.rev

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Spiros Bousbouras on Wed Jan 11 06:55:51 2023
    On Wednesday, January 11, 2023 at 10:19:31 PM UTC+8, Spiros Bousbouras wrote:
    On Wed, 11 Jan 2023 00:41:02 -0800 (PST)
    "[email protected]" <[email protected]> wrote:
    On Tuesday, January 10, 2023 at 10:27:41 PM UTC+8, [email protected] wrote:
    On Tuesday, January 10, 2023 at 9:41:10 PM UTC+8, Geoff Clare wrote:
    Janis Papanagnou wrote:

    On 10.01.2023 09:32, [email protected] wrote:

    As you can see, if I combine the above two sed commands into a single sed
    call, the last line will be blank in the output, as shown in the testing 1.

    Is there any explanation for this behavior?
    REs are matched against the "pattern space", not individual lines within the pattern space. Normally the pattern space only contains
    one line, but the substitution with a \n on the right hand side makes it contain multiple lines. Try this:

    sed -Ee 's/[ ]+/\n/g;s/\n$//'
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    Solution given.
    P.S. Based on the discussion here [1], the reason for the problem here
    is explained in the info of sed, but not in man:

    werner@X10DAi:~$ sed --version |head -3
    sed (GNU sed) 4.8
    Packaged by Debian
    Copyright (C) 2020 Free Software Foundation, Inc.

    werner@X10DAi:~$ info sed |grep -A5 -i 'In a substitution command'
    In a substitution command, the 'w' flag writes the substitution
    result to a file, and the 'e' flag executes the subsitution result
    as a shell command. As with the 'r/R/w/W/e' commands, these must
    be terminated with a newline. If whitespace, comments or
    semicolons are found, they will be included in the shell command or filename, leading to unexpected results:
    No , this quote is unrelated. The explanation for the beaviour you observed (I wouldn't call it a problem) is explained by Geoff above and he gives a solution too.

    Who is Geoff?

    [1] http://pari.math.u-bordeaux.fr/archives/pari-users-2301/msg00049.html

    --
    Forth is a strange combination of computer language and religion.
    Sol Guber at http://mirror.optus.com.au/pub/forth/Archive/docs/mforth.rev

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to [email protected] on Wed Jan 11 17:04:15 2023
    On 11.01.2023 15:55, [email protected] wrote:

    Who is Geoff?

    Not a person, just an acronym; General Expert Of Fabulous Facts.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to [email protected] on Wed Jan 11 15:33:49 2023
    On Wed, 11 Jan 2023 06:55:51 -0800 (PST)
    "[email protected]" <[email protected]> wrote:
    Who is Geoff?

    Who knows ? So many names , so many people , it's hard to keep track of
    all of them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to [email protected] on Wed Jan 11 15:18:59 2023
    In article <[email protected]>, [email protected] <[email protected]> wrote:
    ...
    Who is Geoff?

    Who is John Galt?

    --

    First of all, I do not appreciate your playing stupid here at all.

    - Thomas 'PointedEars' Lahn -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Janis Papanagnou on Wed Jan 11 18:01:34 2023
    On Thursday, January 12, 2023 at 12:04:20 AM UTC+8, Janis Papanagnou wrote:
    On 11.01.2023 15:55, [email protected] wrote:

    Who is Geoff?
    Not a person, just an acronym; General Expert Of Fabulous Facts.

    I have since examined the previous discussions of this thread and feel that the name Geoff, in the context of this topic, must refer to "Geoff Clare", who had posted nice comments on the question here: https://groups.google.com/g/comp.unix.shell/c/
    xOUgJUut6b8/m/EFQy8LKECAAJ.

    Janis
    Zhao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geoff Clare@21:1/5 to Janis Papanagnou on Thu Jan 12 13:21:01 2023
    Janis Papanagnou wrote:

    On 11.01.2023 15:55, [email protected] wrote:

    Who is Geoff?

    Not a person, just an acronym; General Expert Of Fabulous Facts.

    Thanks for that Janis. Can't remember the last time a Usenet post
    made me laugh out loud.

    --
    Geoff Clare <[email protected]>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ed Morton@21:1/5 to [email protected] on Fri Jan 13 09:05:16 2023
    On 1/10/2023 8:23 AM, [email protected] wrote:
    On Tuesday, January 10, 2023 at 8:38:49 PM UTC+8, Janis Papanagnou wrote:
    On 10.01.2023 09:32, [email protected] wrote:
    See my following 2 testings:

    Testing 1:

    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g;/^$/d' | tail | cat -A
    <snip>
    $ gp
    ksh: gp: not found [No such file or directory]

    gp is an easy-to-use interactive shell giving access to the PARI functions:

    https://pari.math.u-bordeaux.fr/

    (Why don't you provide a minimum working example as you've been
    suggested many times already?)

    I'm in a hurry

    YMMV putting your time constraints ahead of the time constraints of
    everyone else who might be willing to try to help you. But, somehow you
    still get answers so I guess you're absolutely right - there's no reason
    for you to try to make it easy for people to help you, just do whatever
    is quickest and easiest for you.

    Ed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Ed Morton on Fri Jan 13 19:41:35 2023
    On Friday, January 13, 2023 at 11:05:20 PM UTC+8, Ed Morton wrote:
    On 1/10/2023 8:23 AM, [email protected] wrote:
    On Tuesday, January 10, 2023 at 8:38:49 PM UTC+8, Janis Papanagnou wrote:
    On 10.01.2023 09:32, [email protected] wrote:
    See my following 2 testings:

    Testing 1:

    werner@X10DAi:~$ echo '?*' | gp -fq | grep -v 'type RETURN' | sed -Ee 's/[ ]+/\n/g;/^$/d' | tail | cat -A
    <snip>
    $ gp
    ksh: gp: not found [No such file or directory]

    gp is an easy-to-use interactive shell giving access to the PARI functions:

    https://pari.math.u-bordeaux.fr/

    (Why don't you provide a minimum working example as you've been
    suggested many times already?)

    I'm in a hurry
    YMMV putting your time constraints ahead of the time constraints of
    everyone else who might be willing to try to help you. But, somehow you
    still get answers so I guess you're absolutely right - there's no reason
    for you to try to make it easy for people to help you, just do whatever
    is quickest and easiest for you.

    Everything in the world has its own reason. The difficulties and ease in form certainly have a corresponding impact. However, they are relative, after all.

    The Internet is so huge, and the *nix and open source world are so rich and colorful. You never know what you find difficult may just be the easiest and favorite thing in another person's eyes.

    Ed.
    Zhao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to [email protected] on Sat Jan 14 11:42:00 2023
    On 14.01.2023 04:41, [email protected] wrote:
    On Friday, January 13, 2023 at 11:05:20 PM UTC+8, Ed Morton wrote:

    (Why don't you provide a minimum working example as you've been
    suggested many times already?)

    I'm in a hurry
    YMMV putting your time constraints ahead of the time constraints of
    everyone else who might be willing to try to help you. But,
    somehow you still get answers so I guess you're absolutely right -
    there's no reason for you to try to make it easy for people to help
    you, just do whatever is quickest and easiest for you.

    [...]

    The Internet is so huge, and the *nix and open source world are so
    rich and colorful. You never know what you find difficult may just be
    the easiest and favorite thing in another person's eyes.

    You seem to be basically talking about the topics (the "difficulties")
    while Ed was talking about mindset and personal posting habit.


    Ed.
    Zhao


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to [email protected] on Sat Jan 14 12:17:07 2023
    In article <tpu0to$1uqpk$[email protected]>,
    Janis Papanagnou <[email protected]> wrote:
    ...
    You seem to be basically talking about the topics (the "difficulties")
    while Ed was talking about mindset and personal posting habit.

    What does that mean?

    --
    The motto of the GOP "base": You can't *be* a billionaire, but at least you
    can vote like one.

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