help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is there a compile option to enable # and % substitution in // and a


From: Greg Wooledge
Subject: Re: is there a compile option to enable # and % substitution in // and available in [[ ==
Date: Thu, 25 Mar 2021 08:28:44 -0400

On Thu, Mar 25, 2021 at 03:26:40AM +0100, Alex fxmbsw7 Ratchev wrote:
> needed to match # and % in a string and figured it didnt work in [[ ==
> i know in // instead of / it doesnt work also
> 
> i think disabling this functionality is nothing good

Please show an example of what you tried, what results you got, and
then tell us what (different) results you expected.

Your example should ideally be ONE command, not some tarball of multiple
files.  If you need 2 or 3 commands to set up variables or functions,
that's OK.  Just paste a terminal session snippet showing the commands
being executed, with no additional unnecessary cruft.

For instance:

unicorn:~$ string='10% off!'; if [[ $string = *%* ]]; then echo match; fi
match

Also remember that # and % have special meanings when used as the first
character of the pattern part of ${parameter/pattern/string}.  This is
documented in the man page.

unicorn:~$ string='my #1 fan'; echo "${string/#[[:digit:]]/}"
my #1 fan
unicorn:~$ string='my #1 fan'; echo "${string/\#[[:digit:]]/}"
my  fan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]