From: "Alexandros Kozak" <agkozak@gmail.com>
To: "'TJ Luoma'" <luomat@gmail.com>, "'Zsh-Users List'" <zsh-users@zsh.org>
Subject: RE: removing spaces in variables when using :t or :r or similar
Date: Tue, 11 Sep 2018 18:35:18 -0700 [thread overview]
Message-ID: <006401d44a38$dd948870$98bd9950$@gmail.com> (raw)
In-Reply-To: <CADjGqHvZESTxjvAAiiSp34i4nk=c+pL=pNiDqEWBHoM2YMouDA@mail.gmail.com>
${${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
next prev parent reply other threads:[~2018-09-12 1:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 1:28 TJ Luoma
2018-09-12 1:35 ` Alexandros Kozak [this message]
2018-09-12 5:07 ` TJ Luoma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='006401d44a38$dd948870$98bd9950$@gmail.com' \
--to=agkozak@gmail.com \
--cc=luomat@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).