[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ubuntu-users
Subject:    =?UTF-8?B?UmU6IEJhc2ggc3Vic3RyaW5ncyDigJMganVzdCBjYW7igJl0IGZpZ3VyZSBpdCBvdXQ=?= =?UTF-8?B?4oCm?=
From:       gurus.knugum () gmail ! com (Johnny Rosenberg)
Date:       2012-01-31 19:40:53
Message-ID: CADo7T4cVpHWYUsB-w2KFYX3-1CuTw7A_sPHqns+GTEowsA0BNA () mail ! gmail ! com
[Download RAW message or body]

2012/1/31 Jonathan Hudson <jh+ubuntu at daria.co.uk>:
> On Tue, 31 Jan 2012 19:55:24 +0100, Johnny Rosenberg wrote:
>
>>2012/1/31 Jonathan Hudson <jh+ubuntu at daria.co.uk>:
>>> On Tue, 31 Jan 2012 12:31:06 -0600, Cybe R. Wizard wrote:
>>>
>>>>On Tue, 31 Jan 2012 19:07:20 +0100
>>>>Johnny Rosenberg <gurus.knugum at gmail.com> wrote:
>>>>
>>>>> I have an example here:
>>>>> File="03. Rock Nuts.flac"
>>>>> echo "${File##N*s}"
>>>>>
>>>>> The result should be ?03. Rock .flac?, shouldn't it? Obviously not,
>>>>> because the result is ?03. Rock Nuts.flac?, which is exactly the
>>>>> original string.
>>>>> So what am I missing?
>>>
>>> That it's a string substitution, not a glob or wildcard match.
>>
>>What's a ?glob?? English is not my native language, sorry. I try the
>>best I can though.
>>
>>> Try
>>>
>>> $ echo ${File//N*s}
>>
>>That worked, but somehow I still don't understand exactly why my
>>example didn't? *confused*
>>
>>
> First ## is a glob (pattern match), apologies. The reason why your ##
> doesn't work is because (a) it is the prefix match, not a suffix match
> and (b) it tries to match the whole remainder of the string (which ends
> in 'c', not 's), whilst // is a replacement.
>
> $ echo ${File%%N*c}
>
> illustrates the suffix (end bit) match.
>
> and
>
> $ echo ${File##03. }
>
> shows the prefix match.
>
> -jh

Aaaah, so I can only match from any character to the last character or
from the first to the last character? Ok, that's maybe useful in some
situations. So in my case, I would need two lines to obtain what I'm
trying to do:
Title=${File##03. }
Title=${Title%%.*c}

$ echo $Title
Rock Nuts

Well, at least it works, but a one-liner would be nice?

I found that the ?c? is very unnecessary. This seems to work the same way:
Title=${File#* }
Title=${Title%.*}


Kind regards

Johnny Rosenberg
????????????


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic