From: Bart Schaefer <schaefer@brasslantern.com>
To: TJ Luoma <luomat@gmail.com>
Cc: Zsh MailingList <zsh-users@zsh.org>
Subject: Re: Expanding a variable extracted from another file
Date: Sat, 16 May 2020 00:03:09 -0700 [thread overview]
Message-ID: <CAH+w=7ZXCu__nZwGEjsJ8vrXUsXommS=EkH-ScJ+tKLw2ph8hg@mail.gmail.com> (raw)
In-Reply-To: <CADjGqHt8oF0W9AEU+j+yJHfOxxrVh-6HFP8ediAT0A_+qX9N8A@mail.gmail.com>
On Fri, May 15, 2020 at 11:48 PM TJ Luoma <luomat@gmail.com> wrote:
>
> Assume I have a plain text file "$HOME/MyReferenceDoc.txt" which has
> these lines:
>
> "$HOME/glue/sticks"
> "$HOME/foo/bar"
> "$HOME/work/files"
>
> And I want to get the matching line which has '/foo/'
MYVAR=${(f@M)$(<~/MyReferenceDoc.txt):#*/foo/*}
> My question is: How can I tell zsh the it should expand the "$HOME" in
> "$MYVAR" to "/home/james"?
print -r -- ${(Qe)MYVAR}
Or leave out the Q if you want the double-quotes preserved.
next prev parent reply other threads:[~2020-05-16 7:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 6:46 TJ Luoma
2020-05-16 7:03 ` Bart Schaefer [this message]
2020-05-16 7:13 ` Roman Perepelitsa
2020-05-16 16:58 ` Bart Schaefer
2020-05-17 12:10 ` TJ Luoma
2020-05-16 21:27 ` Daniel Shahaf
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='CAH+w=7ZXCu__nZwGEjsJ8vrXUsXommS=EkH-ScJ+tKLw2ph8hg@mail.gmail.com' \
--to=schaefer@brasslantern.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).