* removing spaces in variables when using :t or :r or similar
@ 2018-09-12 1:28 TJ Luoma
2018-09-12 1:35 ` Alexandros Kozak
0 siblings, 1 reply; 3+ messages in thread
From: TJ Luoma @ 2018-09-12 1:28 UTC (permalink / raw)
To: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 657 bytes --]
Let's use this variable as an example:
INSTALL_TO='/Applications/Keyboard Maestro.app'
Now, if I want to get just "keyboard maestro" I can use this:
$INSTALL_TO:t:r:l
But what if I want "keyboardmaestro" ?
I tried this:
echo "${INSTALL_TO:t:r:l// /}"
but that just produced this error:
zsh: unrecognized modifier
I realize I could do this:
FOO="${INSTALL_TO// /}"
echo "$FOO:t:r:l"
but I'd rather avoid using a second variable, if I can avoid it.
Is there a way to do that with zsh, or am I stuck just sending it to `tr -d
' '` ?
Thanks!
TjL
--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: removing spaces in variables when using :t or :r or similar
2018-09-12 1:28 removing spaces in variables when using :t or :r or similar TJ Luoma
@ 2018-09-12 1:35 ` Alexandros Kozak
2018-09-12 5:07 ` TJ Luoma
0 siblings, 1 reply; 3+ messages in thread
From: Alexandros Kozak @ 2018-09-12 1:35 UTC (permalink / raw)
To: 'TJ Luoma', 'Zsh-Users List'
${${INSTALL_TO:t:r:l}// /}
seems to work.
Alexandros Kozak
-----Original Message-----
From: TJ Luoma <luomat@gmail.com>
Sent: Tuesday, September 11, 2018 6:28 PM
To: Zsh-Users List <zsh-users@zsh.org>
Subject: removing spaces in variables when using :t or :r or similar
Let's use this variable as an example:
INSTALL_TO='/Applications/Keyboard Maestro.app'
Now, if I want to get just "keyboard maestro" I can use this:
$INSTALL_TO:t:r:l
But what if I want "keyboardmaestro" ?
I tried this:
echo "${INSTALL_TO:t:r:l// /}"
but that just produced this error:
zsh: unrecognized modifier
I realize I could do this:
FOO="${INSTALL_TO// /}"
echo "$FOO:t:r:l"
but I'd rather avoid using a second variable, if I can avoid it.
Is there a way to do that with zsh, or am I stuck just sending it to `tr -d ' '` ?
Thanks!
TjL
--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: removing spaces in variables when using :t or :r or similar
2018-09-12 1:35 ` Alexandros Kozak
@ 2018-09-12 5:07 ` TJ Luoma
0 siblings, 0 replies; 3+ messages in thread
From: TJ Luoma @ 2018-09-12 5:07 UTC (permalink / raw)
To: agkozak; +Cc: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]
Aha! I had tried extra quotes and {brackets} but I never hit upon the right
combination.
Thanks!
Tj
--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>
On Tue, Sep 11, 2018 at 9:35 PM Alexandros Kozak <agkozak@gmail.com> wrote:
> ${${INSTALL_TO:t:r:l}// /}
>
> seems to work.
>
>
> Alexandros Kozak
>
> -----Original Message-----
> From: TJ Luoma <luomat@gmail.com>
> Sent: Tuesday, September 11, 2018 6:28 PM
> To: Zsh-Users List <zsh-users@zsh.org>
> Subject: removing spaces in variables when using :t or :r or similar
>
> Let's use this variable as an example:
>
> INSTALL_TO='/Applications/Keyboard Maestro.app'
>
> Now, if I want to get just "keyboard maestro" I can use this:
>
> $INSTALL_TO:t:r:l
>
> But what if I want "keyboardmaestro" ?
>
> I tried this:
>
> echo "${INSTALL_TO:t:r:l// /}"
>
> but that just produced this error:
>
> zsh: unrecognized modifier
>
> I realize I could do this:
>
> FOO="${INSTALL_TO// /}"
>
> echo "$FOO:t:r:l"
>
> but I'd rather avoid using a second variable, if I can avoid it.
>
> Is there a way to do that with zsh, or am I stuck just sending it to `tr
> -d ' '` ?
>
> Thanks!
>
> TjL
>
> --
> TJ Luoma
> TJ @ MacStories
> Personal Website: luo.ma (aka RhymesWithDiploma.com)
> Twitter: @tjluoma
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-12 5:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 1:28 removing spaces in variables when using :t or :r or similar TJ Luoma
2018-09-12 1:35 ` Alexandros Kozak
2018-09-12 5:07 ` TJ Luoma
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).