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: Alex fxmbsw7 Ratchev
Subject: Re: is there a compile option to enable # and % substitution in // and available in [[ ==
Date: Fri, 26 Mar 2021 22:02:44 +0100

a simple solution to that issue:

IFS=$'\1' str=$IFS"$*"$IFS
[[ $str == *$IFS"str"$IFS* ]]

prepend sep infront and after, array to string definition by same sep IFS

On Fri, Mar 26, 2021 at 10:01 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>
> well there was a #bash issue to check old outdated style strings or
> arrays for content
> besides for loop
> i came up, but it didnt work, with # and % containing in [[ but also
> in @( .. ) inside ${var/ and inside those it also doesnt get
> recognized
>
> On Thu, Mar 25, 2021 at 1:29 PM Greg Wooledge <greg@wooledge.org> wrote:
> >
> > 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]