Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Paramater subsiution



Jun 27, 2021 17:42:48 Lewis Butler <lbutler@xxxxxxxxxx>:

> Given:
>
> name="file 1234 - name"
> echo ${I% - name}
>
> I can easily get 'file', but how would I get "name" instead given that:
>
>   o name and 1234 are variable lengths and values
>   o "file" and " - " are constant across all the input

echo ${i##* - }

Removes the longest prefix ending with ' - '.

Check man zshexpn for more.




Messages sorted by: Reverse Date, Date, Thread, Author