Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

God doesn't play dice. -- Albert Einstein


devel / comp.unix.shell / "sed" question

SubjectAuthor
* "sed" questionOttavio Caruso
+* Re: "sed" questionOttavio Caruso
|+* Re: "sed" questionJanis Papanagnou
||+* Re: "sed" questionGrant Taylor
|||`* Re: "sed" questionJanis Papanagnou
||| `* Re: "sed" questionGrant Taylor
|||  `* Re: "sed" questionKeith Thompson
|||   +- Re: "sed" questionKeith Thompson
|||   `- Re: "sed" questionGrant Taylor
||`- Re: "sed" questionChristian Weisgerber
|+* Re: "sed" questionJulieta Shem
||+* Re: "sed" questionKeith Thompson
|||+- Re: "sed" questionJanis Papanagnou
|||`* Re: "sed" questionOttavio Caruso
||| +- Re: "sed" questionKenny McCormack
||| `* Re: "sed" questionKeith Thompson
|||  +* Re: "sed" questionvallor
|||  |+- Re: "sed" questionKenny McCormack
|||  |`- Re: "sed" questionKeith Thompson
|||  `- Re: "sed" questionJulieta Shem
||`- Re: "sed" questionOttavio Caruso
|`- Re: "sed" questionLawrence D'Oliveiro
+* Re: "sed" questionKenny McCormack
|`- Re: "sed" questionOttavio Caruso
+* Re: "sed" questionGrant Taylor
|`* Re: "sed" questionKenny McCormack
| `* Re: "sed" questionGrant Taylor
|  `- Re: "sed" questionOttavio Caruso
`- Re: "sed" questionKeith Thompson

Pages:12
"sed" question

<us9vka$fepq$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7638&group=comp.unix.shell#7638

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: "sed" question
Date: Wed, 6 Mar 2024 14:46:34 +0000
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <us9vka$fepq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Mar 2024 14:46:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="72d69928ffd6f1b85df32a49c77ebd84";
logging-data="506682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/He9JDpVH3exvG59A6qxZpHZkBYVMX9WI="
Cancel-Lock: sha1:6jcqXv3ZHLnEAGly3mWeZRC/W6o=
Content-Language: en-GB
X-No-Archive: Yes
 by: Ottavio Caruso - Wed, 6 Mar 2024 14:46 UTC

I have a file that looks like this:

$ head newsrc-news.eternal-september.org-test
nl.newsgroups.announce: 1-1329
free.uk.amateur-radio: 1-15497
uk.media.radio.misc: 1-456
uk.radio.amateur: 1-377688,377690,377692,377694-377697,377699,377701-377704
uk.radio.amateur.moderated: 1-6432
uk.legal.moderated: 1-378428
comp.security.ssh: 1-3221
alt.comp.software.newsreaders: 1-481
uk.net.news.moderation: 1-64428
free.uk.legal: 1-275

I want to convert all the last part of the lines from 1-whatever to 1-1

I have tried:

$ sed -i 's/"1-*"/'1-1'/g' newsrc-news.eternal-september.org-test

and

$ sed -i 's/"1-*"/"1-1"/g' newsrc-news.eternal-september.org-test

$ sed -i 's/"1-*"/1-1/g' newsrc-news.eternal-september.org-test

but none of them does the job.

If I do:

$ sed -i 's/1-*/"1-1"/g' newsrc-news.eternal-september.org-test

then:

$ head newsrc-news.eternal-september.org-test
nl.newsgroups.announce: "1-1""1-1""1-1""1-1"329
free.uk.amateur-radio: "1-1""1-1""1-1""1-1"5497
uk.media.radio.misc: "1-1""1-1"456
uk.radio.amateur:
"1-1""1-1"377688,377690,377692,377694-377697,377699,37770"1-1""1-1"377704
uk.radio.amateur.moderated: "1-1""1-1"6432
uk.legal.moderated: "1-1""1-1"378428
comp.security.ssh: "1-1""1-1"322"1-1""1-1"
alt.comp.software.newsreaders: "1-1""1-1"48"1-1""1-1"
uk.net.news.moderation: "1-1""1-1"64428
free.uk.legal: "1-1""1-1"275

which is not what I want.

Any help will be appreciated.

--
Ottavio Caruso

Re: "sed" question

<usa01v$fj5h$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7639&group=comp.unix.shell#7639

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 14:53:51 +0000
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <usa01v$fj5h$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Mar 2024 14:53:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="72d69928ffd6f1b85df32a49c77ebd84";
logging-data="511153"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r9Gu9Kkq+DRe2qcEZ34beK8WKA+F6jlk="
Cancel-Lock: sha1:bz4cDWhsCFnx5lWQmWRwqdDcjXg=
X-No-Archive: Yes
In-Reply-To: <us9vka$fepq$1@dont-email.me>
Content-Language: en-GB
 by: Ottavio Caruso - Wed, 6 Mar 2024 14:53 UTC

Am 06/03/2024 um 14:46 schrieb Ottavio Caruso:
> I have a file that looks like this:
>
> $ head newsrc-news.eternal-september.org-test
> nl.newsgroups.announce: 1-1329
> free.uk.amateur-radio: 1-15497
> uk.media.radio.misc: 1-456
> uk.radio.amateur: 1-377688,377690,377692,377694-377697,377699,377701-377704
> uk.radio.amateur.moderated: 1-6432
> uk.legal.moderated: 1-378428
> comp.security.ssh: 1-3221
> alt.comp.software.newsreaders: 1-481
> uk.net.news.moderation: 1-64428
> free.uk.legal: 1-275
>
> I want to convert all the last part of the lines from 1-whatever to 1-1
>
> I have tried:
>
> $ sed -i 's/"1-*"/'1-1'/g'  newsrc-news.eternal-september.org-test
>
> and
>
> $ sed -i 's/"1-*"/"1-1"/g'  newsrc-news.eternal-september.org-test
>
> $ sed -i 's/"1-*"/1-1/g'  newsrc-news.eternal-september.org-test
>
> but none of them does the job.
>
> If I do:
>
> $ sed -i 's/1-*/"1-1"/g'  newsrc-news.eternal-september.org-test
>
> then:
>
> $ head  newsrc-news.eternal-september.org-test
> nl.newsgroups.announce: "1-1""1-1""1-1""1-1"329
> free.uk.amateur-radio: "1-1""1-1""1-1""1-1"5497
> uk.media.radio.misc: "1-1""1-1"456
> uk.radio.amateur:
> "1-1""1-1"377688,377690,377692,377694-377697,377699,37770"1-1""1-1"377704
> uk.radio.amateur.moderated: "1-1""1-1"6432
> uk.legal.moderated: "1-1""1-1"378428
> comp.security.ssh: "1-1""1-1"322"1-1""1-1"
> alt.comp.software.newsreaders: "1-1""1-1"48"1-1""1-1"
> uk.net.news.moderation: "1-1""1-1"64428
> free.uk.legal: "1-1""1-1"275
>
>
> which is not what I want.
>
> Any help will be appreciated.
>

For posterity, Grant Taylor on alt.comp.software.thunderbird suggested
this and worked:

$ awk '{print $1, "1-1"}' newsrc-news.eternal-september.org-test >
newsrc-news.eternal-september.org

Sorry for the noise. I never got to learn awk properly.

--
Ottavio Caruso

Re: "sed" question

<usa0bt$25tqp$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7640&group=comp.unix.shell#7640

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 14:59:09 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <usa0bt$25tqp$1@news.xmission.com>
References: <us9vka$fepq$1@dont-email.me>
Injection-Date: Wed, 6 Mar 2024 14:59:09 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2291545"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 6 Mar 2024 14:59 UTC

In article <us9vka$fepq$1@dont-email.me>,
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> wrote:
>I have a file that looks like this:
>
>$ head newsrc-news.eternal-september.org-test
>nl.newsgroups.announce: 1-1329
>free.uk.amateur-radio: 1-15497
>uk.media.radio.misc: 1-456
>uk.radio.amateur: 1-377688,377690,377692,377694-377697,377699,377701-377704
>uk.radio.amateur.moderated: 1-6432
>uk.legal.moderated: 1-378428
>comp.security.ssh: 1-3221
>alt.comp.software.newsreaders: 1-481
>uk.net.news.moderation: 1-64428
>free.uk.legal: 1-275
>
>I want to convert all the last part of the lines from 1-whatever to 1-1

Two comments:
1) "sed" is almost never the right answer, regardless of what the
question is. AWK can do everything (with maybe one or two obscure
exceptions) that sed can do, and is a lot easier to use.

2) Why not just:

awk 'sub(/1-[0-9]+$/,"1-1");{ print "Line:",$0,"does not fit the expected pattern." > "/dev/stderr" }' yourfile

--
Many (most?) Trump voters voted for him because they thought if they
supported Trump enough, they'd get to *be* Trump.

Similarly, Trump believes that if *he* praises Putin enough, he'll get to *be* Putin.

Re: "sed" question

<usa11g$fouh$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7641&group=comp.unix.shell#7641

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 15:10:40 +0000
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <usa11g$fouh$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa0bt$25tqp$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Mar 2024 15:10:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="72d69928ffd6f1b85df32a49c77ebd84";
logging-data="517073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pwMPiws7NPtfrzzmhK3DB218/7URF+Xo="
Cancel-Lock: sha1:+jm2P8CLW+zjMt5lhC28TFXNnw4=
Content-Language: en-GB
X-No-Archive: Yes
In-Reply-To: <usa0bt$25tqp$1@news.xmission.com>
 by: Ottavio Caruso - Wed, 6 Mar 2024 15:10 UTC

Am 06/03/2024 um 14:59 schrieb Kenny McCormack:
> In article <us9vka$fepq$1@dont-email.me>,
> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> wrote:
>> I have a file that looks like this:
>>
>> $ head newsrc-news.eternal-september.org-test
>> nl.newsgroups.announce: 1-1329
>> free.uk.amateur-radio: 1-15497
>> uk.media.radio.misc: 1-456
>> uk.radio.amateur: 1-377688,377690,377692,377694-377697,377699,377701-377704
>> uk.radio.amateur.moderated: 1-6432
>> uk.legal.moderated: 1-378428
>> comp.security.ssh: 1-3221
>> alt.comp.software.newsreaders: 1-481
>> uk.net.news.moderation: 1-64428
>> free.uk.legal: 1-275
>>
>> I want to convert all the last part of the lines from 1-whatever to 1-1
>
> Two comments:
> 1) "sed" is almost never the right answer, regardless of what the
> question is. AWK can do everything (with maybe one or two obscure
> exceptions) that sed can do, and is a lot easier to use.
>
> 2) Why not just:
>
> awk 'sub(/1-[0-9]+$/,"1-1");{ print "Line:",$0,"does not fit the expected pattern." > "/dev/stderr" }' yourfile
>

I actually got myself in trouble because I realised this is not what I
really wanted, so I just made a lot of noise for nuffink.

--
Ottavio Caruso

Re: "sed" question

<usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7642&group=comp.unix.shell#7642

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 09:17:38 -0600
Organization: TNet Consulting
Message-ID: <usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>
References: <us9vka$fepq$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Mar 2024 15:17:38 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="571"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <us9vka$fepq$1@dont-email.me>
 by: Grant Taylor - Wed, 6 Mar 2024 15:17 UTC

On 3/6/24 08:46, Ottavio Caruso wrote:
> Any help will be appreciated.

Copying my sed version reply from alt.comp.software.thunderbird here for
completeness:

mv newsrc newsrc.backup
sed 's/:.*/: 1-1/' newsrc.backup > newsrc

--
Grant. . . .

Re: "sed" question

<usa1k4$25tqp$2@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7643&group=comp.unix.shell#7643

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 15:20:36 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <usa1k4$25tqp$2@news.xmission.com>
References: <us9vka$fepq$1@dont-email.me> <usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>
Injection-Date: Wed, 6 Mar 2024 15:20:36 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2291545"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 6 Mar 2024 15:20 UTC

In article <usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>,
Grant Taylor <gtaylor@tnetconsulting.net> wrote:
>On 3/6/24 08:46, Ottavio Caruso wrote:
>> Any help will be appreciated.
>
>Copying my sed version reply from alt.comp.software.thunderbird here for
>completeness:
>
>mv newsrc newsrc.backup
>sed 's/:.*/: 1-1/' newsrc.backup > newsrc

sed -i 's/:.*/: 1-1/' newsrc

--
Most Southerners interest in, knowledge of, and participation in politics begins with
and ends with: Screw the blacks. If a guy is onboard with that, he's our guy!

Get them back in chains where they belong!

Re: "sed" question

<usagql$j9bc$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7645&group=comp.unix.shell#7645

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 20:40:04 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <usagql$j9bc$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Mar 2024 19:40:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="024c656a7db78909e950d23f4a7759c5";
logging-data="632172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182TBXGM063m+qm4LahccuY"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:km4M2hT0KtYvcrFYQzEizI+04MU=
In-Reply-To: <usa01v$fj5h$1@dont-email.me>
 by: Janis Papanagnou - Wed, 6 Mar 2024 19:40 UTC

On 06.03.2024 15:53, Ottavio Caruso wrote:
> Am 06/03/2024 um 14:46 schrieb Ottavio Caruso:
>> I have a file that looks like this:
>>
>> $ head newsrc-news.eternal-september.org-test
>> nl.newsgroups.announce: 1-1329
>> free.uk.amateur-radio: 1-15497
>> uk.media.radio.misc: 1-456
>> uk.radio.amateur:
>> 1-377688,377690,377692,377694-377697,377699,377701-377704
>> uk.radio.amateur.moderated: 1-6432
>> uk.legal.moderated: 1-378428
>> comp.security.ssh: 1-3221
>> alt.comp.software.newsreaders: 1-481
>> uk.net.news.moderation: 1-64428
>> free.uk.legal: 1-275
>>
>> [...]
>>
>> Any help will be appreciated.
>>
>
> For posterity, Grant Taylor on alt.comp.software.thunderbird suggested
> this and worked:
>
>
> $ awk '{print $1, "1-1"}' newsrc-news.eternal-september.org-test >
> newsrc-news.eternal-september.org

In this specific case of regular data you can simplify that to

awk '$2="1-1"' sourcefile > targetfile

Janis

Re: "sed" question

<874jdjqcfp.fsf@yaxenu.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7647&group=comp.unix.shell#7647

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jshem@yaxenu.org (Julieta Shem)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 06 Mar 2024 18:26:34 -0300
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <874jdjqcfp.fsf@yaxenu.org>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="a7cbed595db9adbe7deeacd556ffa3be";
logging-data="671485"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2Qa/pBGHqAkUvfrLfFPQ5wPoY7uxTrx0="
Cancel-Lock: sha1:4OisXsBqXVb/7t1k2b6xfTv+AvU=
sha1:/hCO91VwoPWV/QsjwGt0KKLqUF0=
 by: Julieta Shem - Wed, 6 Mar 2024 21:26 UTC

Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:

[...]

> Sorry for the noise. I never got to learn awk properly.

The book

The AWK Programming Language
Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
Addison-Wesley Publishing Company, 1988
ISBN 0-201-07981-X

is one of the most interesting books on programming ever written.
(Along with SICP, HtDP and others.)

Re: "sed" question

<87a5nbows3.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7648&group=comp.unix.shell#7648

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 06 Mar 2024 13:50:04 -0800
Organization: None to speak of
Lines: 29
Message-ID: <87a5nbows3.fsf@nosuchdomain.example.com>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ff4e833dde04a11b519e7467d1f3c9e8";
logging-data="680118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191eWeBIcDpDqpHIrfJE9ld"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:SeSMipSBKfbX2fQKj5zndLhBB8c=
sha1:Hyd31Dd5xsh/TJFCQ7McrfNnwRI=
 by: Keith Thompson - Wed, 6 Mar 2024 21:50 UTC

Julieta Shem <jshem@yaxenu.org> writes:
> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>
> [...]
>
>> Sorry for the noise. I never got to learn awk properly.
>
> The book
>
> The AWK Programming Language
> Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
> Addison-Wesley Publishing Company, 1988
> ISBN 0-201-07981-X
>
> is one of the most interesting books on programming ever written.
> (Along with SICP, HtDP and others.)

The second edition was published in 2024.

SICP is "Structure and Interpretation of Computer Programs" by Harold
Abelson and Gerald Jay Sussman with Julie Sussman.

HtDP is "How to Design Programs" by Matthias Felleisen, Robert Bruce
Findler, Matthew Flatt, and Shriram Krishnamurthi.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: "sed" question

<875xxzowea.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7649&group=comp.unix.shell#7649

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 06 Mar 2024 13:58:21 -0800
Organization: None to speak of
Lines: 44
Message-ID: <875xxzowea.fsf@nosuchdomain.example.com>
References: <us9vka$fepq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ff4e833dde04a11b519e7467d1f3c9e8";
logging-data="680118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lhCgrg7ibvN3Jvh+4zYOd"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:s8yqbnihd0bOgfP8Sh4MRPN42MM=
sha1:XC6lanllRyftZTlZalsbFr/wk4M=
 by: Keith Thompson - Wed, 6 Mar 2024 21:58 UTC

Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> I have a file that looks like this:
>
> $ head newsrc-news.eternal-september.org-test
> nl.newsgroups.announce: 1-1329
> free.uk.amateur-radio: 1-15497
> uk.media.radio.misc: 1-456
> uk.radio.amateur: 1-377688,377690,377692,377694-377697,377699,377701-377704
> uk.radio.amateur.moderated: 1-6432
> uk.legal.moderated: 1-378428
> comp.security.ssh: 1-3221
> alt.comp.software.newsreaders: 1-481
> uk.net.news.moderation: 1-64428
> free.uk.legal: 1-275
>
> I want to convert all the last part of the lines from 1-whatever to 1-1
[...]

The numbers are a list of which articles in a newsgroup are marked as
already read (either because you've actually read them, or because you
don't want to see them again).

Changing the list to "1-1", which is equivalent to just "1", means that
you've read article number 1. Depending on the server and the newsgroup,
there may or may not be an article number 1, but marking it as read is
harmless. With "nl.newsgroups.announce: 1-1", your newsreader will show
you all articles in that newsgroup other than article number 1.

But I wonder if what you really want to do is mark *all* articles as
unread, so you can see everything. You can do that by deleting the list
of article numbers.

Of course if you really want to mark article 1 in each newsgroup as read
and all others as unread, that's fine. But marking all articles as
unread is easier and perhaps more likely to be what you want.

sed 's/:.*/:/' is likely to do what you want. In my experience it
doesn't matter whether there's a space after the ':'. I'm presume the
format is documented somewhere.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: "sed" question

<usaqu0$lc0u$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7650&group=comp.unix.shell#7650

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 23:32:31 +0100
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <usaqu0$lc0u$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org> <87a5nbows3.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Mar 2024 22:32:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="024c656a7db78909e950d23f4a7759c5";
logging-data="700446"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FdtHXxcuyMb0mS7lLSE9Q"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LVwY+mEVdZmC6Kq57Wl2IbpGFBk=
In-Reply-To: <87a5nbows3.fsf@nosuchdomain.example.com>
 by: Janis Papanagnou - Wed, 6 Mar 2024 22:32 UTC

On 06.03.2024 22:50, Keith Thompson wrote:
> Julieta Shem <jshem@yaxenu.org> writes:
>>
>> The book
>>
>> The AWK Programming Language
>> Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
>> Addison-Wesley Publishing Company, 1988
>> ISBN 0-201-07981-X
>>
>> is one of the most interesting books on programming ever written.
>
> The second edition was published in 2024.

This is a very notable fact given that the first edition was from 1988!

Janis

Re: "sed" question

<usb5g8$4qa$2@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7651&group=comp.unix.shell#7651

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 19:32:56 -0600
Organization: TNet Consulting
Message-ID: <usb5g8$4qa$2@tncsrv09.home.tnetconsulting.net>
References: <us9vka$fepq$1@dont-email.me>
<usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>
<usa1k4$25tqp$2@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 01:32:56 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="4938"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <usa1k4$25tqp$2@news.xmission.com>
 by: Grant Taylor - Thu, 7 Mar 2024 01:32 UTC

On 3/6/24 09:20, Kenny McCormack wrote:
> sed -i 's/:.*/: 1-1/' newsrc

Agreed /if/ the sed that the OP is using supports `-i`.

My day job has me working across multiple platforms and try to do things
more consistently across the platforms.

--
Grant. . . .

Re: "sed" question

<usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7652&group=comp.unix.shell#7652

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Wed, 6 Mar 2024 19:34:55 -0600
Organization: TNet Consulting
Message-ID: <usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 01:34:55 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="4938"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <usagql$j9bc$1@dont-email.me>
 by: Grant Taylor - Thu, 7 Mar 2024 01:34 UTC

On 3/6/24 13:40, Janis Papanagnou wrote:
> In this specific case of regular data you can simplify that to
>
> awk '$2="1-1"' sourcefile > targetfile

Interesting.

I don't know that I've ever seen (re)defining a field value as part of
the script.

I'll have to file that one away.

Today I learned.

Thank you.

--
Grant. . . .

Re: "sed" question

<usb6pa$ncok$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7653&group=comp.unix.shell#7653

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 02:54:48 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <usb6pa$ncok$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me> <usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 01:54:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1a6b23a8580ce6d33f05b085b6fcc2f4";
logging-data="766740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+c0RAyRXW08EQ7zXEzeGda"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:I8kSKyuuQE2oaDz+J9SGAEDqPTw=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
 by: Janis Papanagnou - Thu, 7 Mar 2024 01:54 UTC

On 07.03.2024 02:34, Grant Taylor wrote:
> On 3/6/24 13:40, Janis Papanagnou wrote:
>> In this specific case of regular data you can simplify that to
>>
>> awk '$2="1-1"' sourcefile > targetfile
>
> Interesting.
>
> I don't know that I've ever seen (re)defining a field value as part of
> the script.

Assigning to a field is possible but you should be aware that the
fields in $0 will become reorganized then... (mind the blank spaces)

awk '$2="NEW"' <<EOT
abc defg ghi
jk lm no pq
EOT

Output:
abc NEW ghi
jk NEW no pq

You see that there's then (per default) only single delimiting
spaces left. You can change that by delimiter OFS, e.g. OFS="\t"
would place TABs in between (but would not preserve the original
spacing).

If you'd want to retain the previous spaces it would require some
other (not so trivial) handling.

Janis

> [...]

Re: "sed" question

<usc2h1$vsku$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7654&group=comp.unix.shell#7654

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 09:48:17 +0000
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <usc2h1$vsku$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 09:48:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6146716edd079213eaed4952e0e38cb4";
logging-data="1045150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Xn53CpVvMQ9snZ8d3QVFGQs9MSV0rg20="
Cancel-Lock: sha1:6tRSeAKj5Nx6vsKpmMdYvDINgDo=
In-Reply-To: <874jdjqcfp.fsf@yaxenu.org>
X-No-Archive: Yes
Content-Language: en-GB
 by: Ottavio Caruso - Thu, 7 Mar 2024 09:48 UTC

Am 06/03/2024 um 21:26 schrieb Julieta Shem:
> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>
> [...]
>
>> Sorry for the noise. I never got to learn awk properly.
>
> The book
>
> The AWK Programming Language
> Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
> Addison-Wesley Publishing Company, 1988
> ISBN 0-201-07981-X
>
> is one of the most interesting books on programming ever written.
> (Along with SICP, HtDP and others.)

Smartass.

--
Ottavio Caruso

Re: "sed" question

<usc2je$vsku$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7655&group=comp.unix.shell#7655

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 09:49:34 +0000
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <usc2je$vsku$2@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org> <87a5nbows3.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 09:49:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6146716edd079213eaed4952e0e38cb4";
logging-data="1045150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JUqqCFiYlxh8iqaHHis+Zsq0WCBae/3Q="
Cancel-Lock: sha1:AjnRgZsdrqIwxr6WETxgCUQqSVY=
Content-Language: en-GB
X-No-Archive: Yes
In-Reply-To: <87a5nbows3.fsf@nosuchdomain.example.com>
 by: Ottavio Caruso - Thu, 7 Mar 2024 09:49 UTC

Am 06/03/2024 um 21:50 schrieb Keith Thompson:
> Julieta Shem <jshem@yaxenu.org> writes:
>> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>>
>> [...]
>>
>>> Sorry for the noise. I never got to learn awk properly.
>>
>> The book
>>
>> The AWK Programming Language
>> Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
>> Addison-Wesley Publishing Company, 1988
>> ISBN 0-201-07981-X
>>
>> is one of the most interesting books on programming ever written.
>> (Along with SICP, HtDP and others.)
>
> The second edition was published in 2024.
>
> SICP is "Structure and Interpretation of Computer Programs" by Harold
> Abelson and Gerald Jay Sussman with Julie Sussman.
>
> HtDP is "How to Design Programs" by Matthias Felleisen, Robert Bruce
> Findler, Matthew Flatt, and Shriram Krishnamurthi.
>

For fucks sake, I know what awk is. I just never bothered learning it.

Just because you see a foreign name, you all expect we live in a cave.

--
Ottavio Caruso

Re: "sed" question

<usc2ns$vsku$3@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7656&group=comp.unix.shell#7656

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 09:51:56 +0000
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <usc2ns$vsku$3@dont-email.me>
References: <us9vka$fepq$1@dont-email.me>
<usa1ei$hr$3@tncsrv09.home.tnetconsulting.net>
<usa1k4$25tqp$2@news.xmission.com>
<usb5g8$4qa$2@tncsrv09.home.tnetconsulting.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 09:51:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6146716edd079213eaed4952e0e38cb4";
logging-data="1045150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WT0Fxj1kOmiQvHr3y2dxMJGKTrGLrhbE="
Cancel-Lock: sha1:k+wRNXn54CNSV1d81nlaM+KQYc4=
In-Reply-To: <usb5g8$4qa$2@tncsrv09.home.tnetconsulting.net>
Content-Language: en-GB
X-No-Archive: Yes
 by: Ottavio Caruso - Thu, 7 Mar 2024 09:51 UTC

Am 07/03/2024 um 01:32 schrieb Grant Taylor:
> On 3/6/24 09:20, Kenny McCormack wrote:
>> sed -i 's/:.*/: 1-1/' newsrc
>
> Agreed /if/ the sed that the OP is using supports `-i`.
>
> My day job has me working across multiple platforms and try to do things
> more consistently across the platforms.
>
>
>

Thanks Grant. I am unsubscribing from this NG, so you won't catch me here.

--
Ottavio Caruso

Re: "sed" question

<uscaiu$274mq$2@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7657&group=comp.unix.shell#7657

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 12:05:50 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <uscaiu$274mq$2@news.xmission.com>
References: <us9vka$fepq$1@dont-email.me> <874jdjqcfp.fsf@yaxenu.org> <87a5nbows3.fsf@nosuchdomain.example.com> <usc2je$vsku$2@dont-email.me>
Injection-Date: Thu, 7 Mar 2024 12:05:50 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2331354"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Thu, 7 Mar 2024 12:05 UTC

In article <usc2je$vsku$2@dont-email.me>,
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> wrote:
....
>For fucks sake, I know what awk is. I just never bothered learning it.

You were responding to Leader Keith. Yes, Keith is an asshole, but he's
our asshole and we love him for it.

>Just because you see a foreign name, you all expect we live in a cave.

Do you even have electricity where you live?

--
Just like Donald Trump today, Jesus Christ had a Messiah complex.

And, in fact, the similarities between the two figures are quite striking.
For example, both have a ragtag band of followers, whose faith cannot be shaken.

Re: "sed" question

<87jzmdoep1.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7658&group=comp.unix.shell#7658

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 07 Mar 2024 14:32:58 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87jzmdoep1.fsf@nosuchdomain.example.com>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org> <87a5nbows3.fsf@nosuchdomain.example.com>
<usc2je$vsku$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="baf60ccaa3a113314bb7d61097e89b2c";
logging-data="1351775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hSRGYsRt152gBx7UUDZJN"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:iotHwW4AGw32ktLnpuyL7tJZ8iE=
sha1:CfdO3NaNO6bwfQoFZLwd3u/KR6g=
 by: Keith Thompson - Thu, 7 Mar 2024 22:32 UTC

Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> Am 06/03/2024 um 21:50 schrieb Keith Thompson:
>> Julieta Shem <jshem@yaxenu.org> writes:
>>> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>>>
>>> [...]
>>>
>>>> Sorry for the noise. I never got to learn awk properly.
>>>
>>> The book
>>>
>>> The AWK Programming Language
>>> Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
>>> Addison-Wesley Publishing Company, 1988
>>> ISBN 0-201-07981-X
>>>
>>> is one of the most interesting books on programming ever written.
>>> (Along with SICP, HtDP and others.)
>> The second edition was published in 2024.
>> SICP is "Structure and Interpretation of Computer Programs" by
>> Harold
>> Abelson and Gerald Jay Sussman with Julie Sussman.
>> HtDP is "How to Design Programs" by Matthias Felleisen, Robert Bruce
>> Findler, Matthew Flatt, and Shriram Krishnamurthi.
>
> For fucks sake, I know what awk is. I just never bothered learning it.
>
> Just because you see a foreign name, you all expect we live in a cave.

What on Earth are you talking about? I didn't even notice your name.
I just expanded on what Julieta Shem wrote, and you somehow managed
to take offense. (I didn't know what HtDP means; I had to look it
up, and then I shared that information with the group.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: "sed" question

<usdk6k$so1$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7659&group=comp.unix.shell#7659

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 7 Mar 2024 17:56:04 -0600
Organization: TNet Consulting
Message-ID: <usdk6k$so1$1@tncsrv09.home.tnetconsulting.net>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me> <usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
<usb6pa$ncok$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 23:56:04 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="29441"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <usb6pa$ncok$1@dont-email.me>
 by: Grant Taylor - Thu, 7 Mar 2024 23:56 UTC

On 3/6/24 19:54, Janis Papanagnou wrote:
> You see that there's then (per default) only single delimiting spaces
> left.

I think I see what you're saying. I also feel like I must be missing
something obvious, because what you're describing is what I would expect
awk to do.

> You can change that by delimiter OFS, e.g. OFS="\t" would place TABs
> in between (but would not preserve the original spacing).

I've dabbled with OFS, and IFS, a few times as needed. But most of the
time I don't need to.

> If you'd want to retain the previous spaces it would require some other
> (not so trivial) handling.

I can't think of a use case where I would want that and choose to use
awk. -- I'm sure such use cases exist, I'm just ignorant of them.

--
Grant. . . .

Re: "sed" question

<87bk7poa7u.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7660&group=comp.unix.shell#7660

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 07 Mar 2024 16:09:41 -0800
Organization: None to speak of
Lines: 46
Message-ID: <87bk7poa7u.fsf@nosuchdomain.example.com>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me>
<usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
<usb6pa$ncok$1@dont-email.me>
<usdk6k$so1$1@tncsrv09.home.tnetconsulting.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="ba4161de3c6afa3b79edb2bdfdc78ddd";
logging-data="1396766"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5lrbk++9pcThFluR/C0sH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:VL8Lmwdb9xacu92WDQhj0ROztXM=
sha1:bVbacCASWxFkURE3qs8az1jNf3Y=
 by: Keith Thompson - Fri, 8 Mar 2024 00:09 UTC

Grant Taylor <gtaylor@tnetconsulting.net> writes:
> On 3/6/24 19:54, Janis Papanagnou wrote:
>> You see that there's then (per default) only single delimiting
>> spaces left.
>
> I think I see what you're saying. I also feel like I must be missing
> something obvious, because what you're describing is what I would
> expect awk to do.

I know that's what awk does, but I don't think I would have expected it
if I didn't know about it.

For example:

$ echo 'one two three' | awk '{print}'
one two three
$ echo 'one two three' | awk '{$0 = $0 " four" ; print}'
one two three four
$ echoʜ'one two three' | awk '{$2 = "TWO" ; print}'
one TWO three
$

$0 is the current input line. If you don't change anything, or if you
modify $0 itself, whitespace betweeen fields is preserved. If you
modify any of the fields, $0 is recomputed and whitespace between tokens
is collapsed.

awk *could* have been defined to preserve inter-field whitespace even
when you modify individual fields, and I think I would have found that
more intuitive. (And ideally there would be a way to refer to that
inter-field whitespace.) The fact that modifying a field has the side
effect of messing up $0 seems counterintuitive.

Perhaps the behavior matches your intuition better than it matches mine.

(And perhaps this should be moved to comp.lang.awk if it doesn't die out
soon. Though both sed and awk are both languages in their own right and
tools that can be used from the shell, so I'd argue there's a topicality
overlap.)

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: "sed" question

<874jdho8ya.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7661&group=comp.unix.shell#7661

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Thu, 07 Mar 2024 16:37:01 -0800
Organization: None to speak of
Lines: 16
Message-ID: <874jdho8ya.fsf@nosuchdomain.example.com>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me>
<usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
<usb6pa$ncok$1@dont-email.me>
<usdk6k$so1$1@tncsrv09.home.tnetconsulting.net>
<87bk7poa7u.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="ba4161de3c6afa3b79edb2bdfdc78ddd";
logging-data="1403278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18M/hzGUkVH3TyFLzD6IXbG"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Q7qVAbem27tTgJxZx3EGCgbbGjg=
sha1:lNg6DnxxQrAvHRaYwAhI+9//5KE=
 by: Keith Thompson - Fri, 8 Mar 2024 00:37 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
> $ echo 'one two three' | awk '{print}'
> one two three
> $ echo 'one two three' | awk '{$0 = $0 " four" ; print}'
> one two three four
> $ echoʜ'one two three' | awk '{$2 = "TWO" ; print}'
> one TWO three
> $

Please ignore the stray ʜ character. It was supposed to be a space.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: "sed" question

<usdtn4$j2n$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7662&group=comp.unix.shell#7662

  copy link   Newsgroups: comp.unix.shell comp.lang.awk
Followup: comp.lang.awk
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell,comp.lang.awk
Subject: Re: "sed" question
Followup-To: comp.lang.awk
Date: Thu, 7 Mar 2024 20:38:28 -0600
Organization: TNet Consulting
Message-ID: <usdtn4$j2n$1@tncsrv09.home.tnetconsulting.net>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<usagql$j9bc$1@dont-email.me> <usb5jv$4qa$3@tncsrv09.home.tnetconsulting.net>
<usb6pa$ncok$1@dont-email.me> <usdk6k$so1$1@tncsrv09.home.tnetconsulting.net>
<87bk7poa7u.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Mar 2024 02:38:28 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="19543"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <87bk7poa7u.fsf@nosuchdomain.example.com>
 by: Grant Taylor - Fri, 8 Mar 2024 02:38 UTC

On 3/7/24 18:09, Keith Thompson wrote:
> I know that's what awk does, but I don't think I would have expected
> it if I didn't know about it.

Okay. I think that's a fair observation.

> $0 is the current input line.

Or $0 is the current /record/ in awk parlance.

> If you don't change anything, or if you modify $0 itself, whitespace
> betweeen fields is preserved.

> If you modify any of the fields, $0 is recomputed and whitespace
> between tokens is collapsed.

I don't agree with that.

% echo 'one two three' | awk '{print $0; print $1,$2,$3}'
one two three
one two three

I didn't /modify/ anything and awk does print the fields with different
white space.

> awk *could* have been defined to preserve inter-field whitespace even
> when you modify individual fields,

I question the veracity of that. Specifically when lengthening or
shortening the value of a field. E.g. replacing "two" with "fifteen".
This is particularly germane when you look at $0 as a fixed width
formatted output.

> and I think I would have found that more intuitive.

I don't agree.

> (And ideally there would be a way to refer to that inter-field
> whitespace.)

Remember, awk is meant for working on fields of data in a record. By
default, the fields are delimited by white space characters. I'll say
it this way, awk is meant for working on the non-white space characters.
Or yet another way, awk is not meant for working on white space charters.

> The fact that modifying a field has the side effect of messing up $0
> seems counterintuitive.

Maybe.

But I think it's one that is acceptable for what awk is intended to do.

> Perhaps the behavior matches your intuition better than it matches
> mine.

I sort of feel like you are wanting to / trying to use awk in places
where sed might be better. sed just sees a string of text and is
ignorant of any structure without a carefully crafted RE to provide it.

Conversely awk is quite happy working with an easily identified field
based on the count with field separators of one or more white space
characters.

Consider the output of `netstat -an` wherein you have multiple columns
of IP addresses.

Please find a quick way, preferably that doesn't involve negation
(because what needs to be negated may bey highly dynamic) that lists
inbound SMTP connections on an email server but doesn't list outbound
SMTP connections.

awk makes it trivial to identify and print records that have the SMTP
port in the local IP column, thus ignoring outbound connections with
SMTP in the remote column.

Aside: Yes, I know that ss and the likes have more features for this,
but this is my example and ss is not installed everywhere.

I sort of view awk as somewhat akin to SQL wherein fields in awk are
like columns in SQL.

I'd be more than a little bit surprised to find an SQL interface that
preserved white space /between/ columns. -- Many will do it /within/
columns.

awk makes it trivial to take field oriented output from commands and
apply some logic / parsing / action on specific fields in records.

> (And perhaps this should be moved to comp.lang.awk if it doesn't die
> out soon.

comp.lang.awk added and followup pointed there.

> Though both sed and awk are both languages in their own right
> and tools that can be used from the shell, so I'd argue there's a
> topicality overlap.)

;-)

--
Grant. . . .

Re: "sed" question

<usdufk$19m29$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7663&group=comp.unix.shell#7663

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Fri, 8 Mar 2024 02:51:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <usdufk$19m29$1@dont-email.me>
References: <us9vka$fepq$1@dont-email.me> <usa01v$fj5h$1@dont-email.me>
<874jdjqcfp.fsf@yaxenu.org> <87a5nbows3.fsf@nosuchdomain.example.com>
<usc2je$vsku$2@dont-email.me> <87jzmdoep1.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 8 Mar 2024 02:51:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="14571b3b95caa9efa0c09db36fd06bc3";
logging-data="1366089"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182tIaWv2UE8xX2ONe59olD"
User-Agent: Pan/0.155 (Kherson; c0bf34e gitlab.gnome.org/GNOME/pan.git;
x86_64-pc-linux-gnu)
Cancel-Lock: sha1:489T1h9h9Oqfv16+pAXh+rJNjeQ=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
 by: vallor - Fri, 8 Mar 2024 02:51 UTC

On Thu, 07 Mar 2024 14:32:58 -0800, Keith Thompson
<Keith.S.Thompson+u@gmail.com> wrote in
<87jzmdoep1.fsf@nosuchdomain.example.com>:

> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>> Am 06/03/2024 um 21:50 schrieb Keith Thompson:
>>> Julieta Shem <jshem@yaxenu.org> writes:
>>>> Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>>>>
>>>> [...]
>>>>
>>>>> Sorry for the noise. I never got to learn awk properly.
>>>>
>>>> The book
>>>>
>>>> The AWK Programming Language Alfred V. Aho, Brian W. Kernighan,
>>>> Peter J. Weinberger Addison-Wesley Publishing Company, 1988 ISBN
>>>> 0-201-07981-X
>>>>
>>>> is one of the most interesting books on programming ever written.
>>>> (Along with SICP, HtDP and others.)
>>> The second edition was published in 2024.
>>> SICP is "Structure and Interpretation of Computer Programs" by Harold
>>> Abelson and Gerald Jay Sussman with Julie Sussman.
>>> HtDP is "How to Design Programs" by Matthias Felleisen, Robert Bruce
>>> Findler, Matthew Flatt, and Shriram Krishnamurthi.
>>
>> For fucks sake, I know what awk is. I just never bothered learning it.
>>
>> Just because you see a foreign name, you all expect we live in a cave.
>
> What on Earth are you talking about? I didn't even notice your name.
> I just expanded on what Julieta Shem wrote, and you somehow managed to
> take offense. (I didn't know what HtDP means; I had to look it up, and
> then I shared that information with the group.)

Someone having a bad day?

Anyway, thank you for the heads-up that a new edition
of the AWK book was out. I bought it on Kindle -- would
have bought hardcopy, but Amazon seems to only have it
in paperback (and Kindle).

(Coincidentally, I have a question about shell providers,
but will post that separately.)

--
-v

Re: "sed" question

<usdvkq$285k8$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7664&group=comp.unix.shell#7664

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: "sed" question
Date: Fri, 8 Mar 2024 03:11:22 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <usdvkq$285k8$1@news.xmission.com>
References: <us9vka$fepq$1@dont-email.me> <usc2je$vsku$2@dont-email.me> <87jzmdoep1.fsf@nosuchdomain.example.com> <usdufk$19m29$1@dont-email.me>
Injection-Date: Fri, 8 Mar 2024 03:11:22 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2365064"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 8 Mar 2024 03:11 UTC

In article <usdufk$19m29$1@dont-email.me>, vallor <vallor@cultnix.org> wrote:
....
>Someone having a bad day?

Yes, but with Keith, every day is a bad day.

You get used to it.

--
'Islamaphobia' is a term created by fascists and used by cowards to manipulate morons.

- Author unknown, quoted by Sam Harris -

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor