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
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?
$ { 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?)
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
Janis Papanagnou wrote:
On 10.01.2023 09:32, [email protected] wrote:REs are matched against the "pattern space", not individual lines
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?
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]>
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:REs are matched against the "pattern space", not individual lines
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?
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
Yes. As shown below:Works for me. (Same output.)That's because the input to sed didn't include any space characters.
Try it with { seq 3 ; echo ' ' ;} | ...
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]>
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:REs are matched against the "pattern space", not individual lines
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?
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$//'
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:
[1] http://pari.math.u-bordeaux.fr/archives/pari-users-2301/msg00049.html
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:REs are matched against the "pattern space", not individual lines within the pattern space. Normally the pattern space only contains
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?
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'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.
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:
[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
Who is Geoff?
Who is Geoff?
Who is Geoff?
On 11.01.2023 15:55, [email protected] wrote:
Who is Geoff?Not a person, just an acronym; General Expert Of Fabulous Facts.
JanisZhao
On 11.01.2023 15:55, [email protected] wrote:
Who is Geoff?
Not a person, just an acronym; General Expert Of Fabulous Facts.
On Tuesday, January 10, 2023 at 8:38:49 PM UTC+8, Janis Papanagnou wrote:<snip>
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
$ 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
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:<snip>
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
$ 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 hurryYMMV 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.Zhao
On Friday, January 13, 2023 at 11:05:20 PM UTC+8, Ed Morton wrote:
YMMV putting your time constraints ahead of the time constraints of
(Why don't you provide a minimum working example as you've been
suggested many times already?)
I'm in a hurry
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.
Ed.Zhao
You seem to be basically talking about the topics (the "difficulties")
while Ed was talking about mindset and personal posting habit.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 145:46:45 |
| Calls: | 12,089 |
| Calls today: | 2 |
| Files: | 15,000 |
| Messages: | 6,517,497 |