[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Strange results
From: |
Dennis Williamson |
Subject: |
Fwd: Strange results |
Date: |
Thu, 26 Oct 2023 12:09:53 -0500 |
---------- Forwarded message ---------
From: Dennis Williamson <dennistwilliamson@gmail.com>
Date: Thu, Oct 26, 2023 at 12:09 PM
Subject: Re: Strange results
To: Victor Pasko <victor.pasko@gmail.com>
echo "echo11 ${ASCII_SET:-10:1}"echo "echo11 ${ASCII_SET:-10:1}"
On Thu, Oct 26, 2023 at 9:54 AM Victor Pasko <victor.pasko@gmail.com> wrote:
> Hi,
>
> echo9 u
> echo10 u
> And the most strange result
> echo11
>
>
> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
>
> --
>
> -- PSK
>
echo "echo9 ${ASCII_SET:$((a-10)):1}"
echo "echo10 ${ASCII_SET:$((-10)):1}"
Both of these say "output the character that's 10th from the end" which is
"u". What did you expect it to output?
echo "echo11 ${ASCII_SET:-10:1}"
This says, according to the man page:
${parameter:-word}
Use Default Values. If parameter is unset or null, the
expansion of word is substituted. Otherwise, the value of parameter is
substituted
which means output "10:1" if ASCII_SET is unset or null. Since it isn't,
the contents of that variable are output giving you a long sequence of
ASCII characters.
--
Visit serverfault.com to get your system administration questions answered.
--
Visit serverfault.com to get your system administration questions answered.
- Strange results, Victor Pasko, 2023/10/26
- Re: Strange results, Chet Ramey, 2023/10/26
- Message not available
- Fwd: Strange results,
Dennis Williamson <=
- Message not available
- Message not available
- Fwd: Strange results, Victor Pasko, 2023/10/26
- Re: Strange results, alex xmb sw ratchev, 2023/10/26
- Re: Fwd: Strange results, Kerin Millar, 2023/10/26
- Re: Fwd: Strange results, Victor Pasko, 2023/10/27
- Re: Fwd: Strange results, Kerin Millar, 2023/10/27
- Re: Fwd: Strange results, Kerin Millar, 2023/10/27
- Re: Fwd: Strange results, Kerin Millar, 2023/10/27