Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11283
| From | Charles Daffern <seejay.11@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: BUG?: (or what's going on?) test for NL == NL fails (bash-4.3.39(3)-release) |
| Date | 2015-08-02 22:15 +0100 |
| Message-ID | <mailman.7768.1438550165.904.bug-bash@gnu.org> (permalink) |
| References | <55BE6FB8.4080200@tlinx.org> <55BE7DD6.3040509@tlinx.org> |
[Multipart message — attachments visible in raw view] - view raw
On 02/08/15 21:30, Linda Walsh wrote:
> Am just looking for an efficient way to test for 0x0a
> as last char in a var, ... after another 20 minutes of
> trying things at random, found this:
>
> > printf "%d\n" "'${a:0-1:1}'"
> 10
>
> Oddly, the final single quote in the string seems unnecessary.
> But that (or into a var: printf -v var) both work...but I
> feel a bit contorted trying so many odd ways to get something
> that I thought would be simple, to work.
Most of the problems here are due to the use of command substitution (as
I mentioned in an earlier response).
The ways I would go about checking for a newline at the end of a string are:
[ "$var" != "${var%$'\n'}" ]
or
[[ $var = *$'\n' ]]
Back to gnu.bash.bug | Previous | Next | Find similar
Re: BUG?: (or what's going on?) test for NL == NL fails (bash-4.3.39(3)-release) Charles Daffern <seejay.11@gmail.com> - 2015-08-02 22:15 +0100
csiph-web