bash syntax [was: m4a->mp3 help]

Jonas Norlander jonorland at gmail.com
Mon Oct 13 16:00:41 UTC 2008


2008/10/13 Nils Kassube <kassube at gmx.net>:
> Jonas Norlander wrote:
>> So in short ${fn%m4a} would match and remove m4a from the end of the
>> string and ${fn#m4a} would from the beginning of the string?
>
> Right.
>
>> But what
>> about the %% and ## syntax?
>
> If you use the "*" wildcard within the string to remove, %% and ## match
> the longest possible string while % and # match the shortest possible
> string. Example:
>
> ~/ > fn=/usr/bin/bison
> ~/ > echo ${fn##*bi}
> son
> ~/ > echo ${fn#*bi}
> n/bison
> ~/ > echo ${fn%bi*}
> /usr/bin/
> ~/ > echo ${fn%%bi*}
> /usr/
>
>
> Nils
>

Thanks! Think i got it now.

/ Jonas




More information about the kubuntu-users mailing list