[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFE: new syntax for command substitution to keep trailing newlines?
From: |
Chet Ramey |
Subject: |
Re: RFE: new syntax for command substitution to keep trailing newlines? |
Date: |
Wed, 27 Jan 2021 15:33:00 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 |
On 1/27/21 3:29 PM, Léa Gris wrote:
Now if you want to preserve all the newlines you can use an ASCII EOF
character (formerly Ctrl + Z) that is unlikely to be part of a legit string:
a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a
It doesn't matter what you use (besides a newline, of course). Just remove
a single character: a=${a%?}.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Re: RFE: new syntax for command substitution to keep trailing newlines?, (continued)
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Alex fxmbsw7 Ratchev, 2021/01/27
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Chet Ramey, 2021/01/27
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Alex fxmbsw7 Ratchev, 2021/01/27
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Chet Ramey, 2021/01/27
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Alex fxmbsw7 Ratchev, 2021/01/29
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Chet Ramey, 2021/01/29
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Alex fxmbsw7 Ratchev, 2021/01/29
- Message not available
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Alex fxmbsw7 Ratchev, 2021/01/30
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Chet Ramey, 2021/01/30
- Re: RFE: new syntax for command substitution to keep trailing newlines?, Léa Gris, 2021/01/27
- Re: RFE: new syntax for command substitution to keep trailing newlines?,
Chet Ramey <=
- Re: RFE: new syntax for command substitution to keep trailing newlines?, pepa65, 2021/01/27
Re: RFE: new syntax for command substitution to keep trailing newlines?, Koichi Murase, 2021/01/27
Re: RFE: new syntax for command substitution to keep trailing newlines?, Clark Wang, 2021/01/27