zsh-users
 help / color / mirror / code / Atom feed
* Expanding a variable extracted from another file
@ 2020-05-16  6:46 TJ Luoma
  2020-05-16  7:03 ` Bart Schaefer
  2020-05-16 21:27 ` Daniel Shahaf
  0 siblings, 2 replies; 6+ messages in thread
From: TJ Luoma @ 2020-05-16  6:46 UTC (permalink / raw)
  To: Zsh MailingList

Sorry for the vague subject,  I'm not 100% sure how to ask this.

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=$(fgrep '/foo/' "$HOME/MyReferenceDoc.txt")

`$MYVAR` will now equal "$HOME/foo/bar" (with literal double-quotes
and a literal '$HOME')

Let's assume my actual home dir is '/home/james'

My question is: How can I tell zsh the it should expand the "$HOME" in
"$MYVAR" to "/home/james"?

Even if I do:

echo "$MYVAR"

I get the literal "$HOME" including double-quotes in the output.

I guess this must be some foundational Unix thing that I don't
understand properly, but all of my attempts to google it have come up
short because I'm not sure what to search for other than "expand
variable" but it's not quite that either.

Thanks

Tj

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-17 12:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16  6:46 Expanding a variable extracted from another file TJ Luoma
2020-05-16  7:03 ` Bart Schaefer
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

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).