Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken


devel / comp.unix.shell / Re: bash: append in place

SubjectAuthor
* bash: append in placeCyrille Lefevre
`- bash: append in placeKenny McCormack

1
Re: bash: append in place

<653b39b4$0$7462$426a34cc@news.free.fr>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!news.mixmin.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-a.proxad.net!nnrp2-1.free.fr!not-for-mail
Date: Fri, 27 Oct 2023 06:16:53 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bash: append in place
Content-Language: fr
Newsgroups: comp.unix.shell
References: <tm85mi$n2c2$2@news.xmission.com>
From: Cyrille.Lefevre-news%nospam@laposte.net.invalid (Cyrille Lefevre)
Organization: ACME
In-Reply-To: <tm85mi$n2c2$2@news.xmission.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 40
Message-ID: <653b39b4$0$7462$426a34cc@news.free.fr>
NNTP-Posting-Date: 27 Oct 2023 06:16:53 CEST
NNTP-Posting-Host: 78.242.206.141
X-Trace: 1698380213 news-4.free.fr 7462 78.242.206.141:37566
X-Complaints-To: abuse@proxad.net
 by: Cyrille Lefevre - Fri, 27 Oct 2023 04:16 UTC

On 30/11/2022 at 18:59, Kenny McCormack wrote :
> Note: not looking for workarounds, got plenty of my own.
> In particular, if you have to code a loop, that takes the fun out of it.
>
> Anyway, suppose I do:
>
> $ set -- foo bar bletch
>
> I want to pass these args to a subprogram with "/*.c" appended to each.
>
> So, I'd like for:
>
> $ someCommand "${@/$/\/*.c}"
>
> to work, but it does not. This is b/c the above bash syntax doesn't deal
> in reg exps; it is some other kind of pattern matcher.
>
> I seem to remember that there is a way to do this, but I can't recall it
> ATM. Any ideas?
>

Hi,

$ set -- cp dd
$ echo ${@/%/\/*.c}
cp/cp.c cp/utils.c dd/args.c dd/conv.c dd/conv_tab.c dd/dd.c dd/gen.c
dd/misc.c dd/position.c
$ echo "${@/%/\/*.c}"
cp/*.c dd/*.c

/% means replace from the end
/# from the beginning

Regards,

Cyrille Lefevre.
--
mailto:Cyrille.Lefevre-news%nospam@laposte.net.invalid
remove "%nospam" and ".invalid" to answer me.

Re: bash: append in place

<uhfugj$2n9su$1@news.xmission.com>

  copy mid

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

  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: bash: append in place
Date: Fri, 27 Oct 2023 09:05:23 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <uhfugj$2n9su$1@news.xmission.com>
References: <tm85mi$n2c2$2@news.xmission.com> <653b39b4$0$7462$426a34cc@news.free.fr>
Injection-Date: Fri, 27 Oct 2023 09:05:23 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2860958"; 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, 27 Oct 2023 09:05 UTC

In article <653b39b4$0$7462$426a34cc@news.free.fr>,
Cyrille Lefevre <Cyrille.Lefevre-news%nospam@laposte.net.invalid> wrote:
>On 30/11/2022 at 18:59, Kenny McCormack wrote :
>> Note: not looking for workarounds, got plenty of my own.
>> In particular, if you have to code a loop, that takes the fun out of it.
>>
>> Anyway, suppose I do:
>>
>> $ set -- foo bar bletch
>>
>> I want to pass these args to a subprogram with "/*.c" appended to each.
>>
>> So, I'd like for:
>>
>> $ someCommand "${@/$/\/*.c}"
>>
>> to work, but it does not. This is b/c the above bash syntax doesn't deal
>> in reg exps; it is some other kind of pattern matcher.
>>
>> I seem to remember that there is a way to do this, but I can't recall it
>> ATM. Any ideas?
>>
>
>Hi,
>
>$ set -- cp dd
>$ echo ${@/%/\/*.c}
>cp/cp.c cp/utils.c dd/args.c dd/conv.c dd/conv_tab.c dd/dd.c dd/gen.c
>dd/misc.c dd/position.c
>$ echo "${@/%/\/*.c}"
>cp/*.c dd/*.c
>
>/% means replace from the end
>/# from the beginning

Yes! Thank you! This is Usenet working as it was intended. A rarity
these days!

And, indeed, I found this in "man bash":

${parameter/pattern/string}
Pattern substitution. The pattern is expanded to produce a pat-
tern just as in pathname expansion. Parameter is expanded and
the longest match of pattern against its value is replaced with
string. If pattern begins with /, all matches of pattern are
replaced with string. Normally only the first match is
replaced. If pattern begins with #, it must match at the begin-
ning of the expanded value of parameter. If pattern begins with
%, it must match at the end of the expanded value of parameter.
If string is null, matches of pattern are deleted and the / fol-
lowing pattern may be omitted. If parameter is @ or *, the sub-
stitution operation is applied to each positional parameter in
turn, and the expansion is the resultant list. If parameter is
an array variable subscripted with @ or *, the substitution
operation is applied to each member of the array in turn, and
the expansion is the resultant list.

The bit about % and # is there in the text. I just never noticed it before.

--
Life's big questions are big in the sense that they are momentous. However, contrary to
appearances, they are not big in the sense of being unanswerable. It is only that the answers
are generally unpalatable. There is no great mystery, but there is plenty of horror.
(https://en.wikiquote.org/wiki/David_Benatar)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor