Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: removing spaces in variables when using :t or :r or similar
- X-seq: zsh-users 23619
- From: "Alexandros Kozak" <agkozak@xxxxxxxxx>
- To: "'TJ Luoma'" <luomat@xxxxxxxxx>, "'Zsh-Users List'" <zsh-users@xxxxxxx>
- Subject: RE: removing spaces in variables when using :t or :r or similar
- Date: Tue, 11 Sep 2018 18:35:18 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=hk0gc8wkmifG5BTZrCu8plg3mymLd7iFnDfbJSrF0UY=; b=juYal+OMa1WYYVxo6BpUV5jEA+o6/daxscA4S+19ksEIuc8Sr7guzkj3Bo93HPPDCz oq1CmzbtxEyXiE+QRqERCRr69MlxF66HqIvNws11vhHyI+s5BHv3WkVZD3yLtGl5CFKL eQ4R2O/f+mlRFFihmC78CRzDyBc6ItAQEfO8+B5GYa4hXfXdJpsbi5MQPRqDh8/m3F2/ aNJFP0baqIhKzbEqoRhX0iTUsrEVMHGMA4+pqQLsKPVojbqQBLhu+DtfJEohm4jxPFQA zrfe9O6SUiq1dxc+E1thIaOORo7AW8M8ZrfzwBsX8X4ZSu5o8HihN6rlumu9E9YNLOTE 4R4g==
- In-reply-to: <CADjGqHvZESTxjvAAiiSp34i4nk=c+pL=pNiDqEWBHoM2YMouDA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHvZESTxjvAAiiSp34i4nk=c+pL=pNiDqEWBHoM2YMouDA@mail.gmail.com>
- Thread-index: AQI9qkQ1S/xln4ekW1d5GB/SeT43xKQZHNDQ
${${INSTALL_TO:t:r:l}// /}
seems to work.
Alexandros Kozak
-----Original Message-----
From: TJ Luoma <luomat@xxxxxxxxx>
Sent: Tuesday, September 11, 2018 6:28 PM
To: Zsh-Users List <zsh-users@xxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author