[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed with Variable Substitution in the command
From: |
alex xmb sw ratchev |
Subject: |
Re: sed with Variable Substitution in the command |
Date: |
Fri, 27 Sep 2024 09:06:20 +0200 |
oh see , sed .. nm , thxx ..
On Thu, Sep 26, 2024 at 6:53 PM alex xmb sw ratchev <fxmbsw7@gmail.com>
wrote:
> sorry .. where is $11 and error ?
>
> On Thursday, September 26, 2024, Wiley Young <wyeth2485@gmail.com> wrote:
>
>> From: Steve Matzura
>> "... Variable substitution has always been a problem for me because
>> there
>> doesn't seem to be a single hard-and-fast rule--sometimes the variable is
>> quoted, sometimes it's wrapped in braces...."
>>
>>
>> Regarding braces, it's always permissible to surround a parameter name in
>> braces, meaning that adding braces won't cause an error. On the other
>> hand,
>> there are numerous situations where omitting braces would cause an error.
>>
>> Okay ??
>> ==== ====
>> "${foo}"
>> "$foo" is okay
>> "${bar##_*}"
>> "$bar##_*" is an error
>> "${1}"
>> "$1" is okay
>> "${11}"
>> "$11" is an error
>> "${array[1]}"
>> "$array[1]" is an error
>>
>> I use the term "error" loosely to mean, unintended effects will occur.
>>
>> Braces are also used for other things as well: compound commands, function
>> definitions, and brace expansion among others. Each of these are something
>> else, though.
>>
>> Just always using braces _is_ extra typing. Some might say that it's less
>> _readable._ Still, doing so lets users more errors while remembering fewer
>> rules.
>>
>> Wiley
>>
>
- Re: sed with Variable Substitution in the command, (continued)
- Re: sed with Variable Substitution in the command, alex xmb sw ratchev, 2024/09/27
- Re: sed with Variable Substitution in the command, Andreas Kähäri, 2024/09/27
- Re: sed with Variable Substitution in the command, alex xmb sw ratchev, 2024/09/27
- Re: sed with Variable Substitution in the command, Andreas Kähäri, 2024/09/27
- Re: sed with Variable Substitution in the command, Greg Wooledge, 2024/09/27
- Re: sed with Variable Substitution in the command, alex xmb sw ratchev, 2024/09/27
- Re: sed with Variable Substitution in the command,
alex xmb sw ratchev <=