Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Can this be extended to any variable name they might think of ? Commented Sep 3, 2016 at 6:59
  • @MikeWarren I could be wrong but I think you would need to write a new parameter expansion for each variable. s="${s//\$HOME/$HOME}" is a substitution parameter expansion. So anytime the variable a contains the substring $HOME then replace it with the expanded value of $HOME. Commented Sep 3, 2016 at 7:06
  • I suspect that is why John1024 may have used the variable name s. So that when it gets used in the parameter expansion i.e. ${s//PATTERN_TO_FIND/REPLACE_STRING} it causes you to say "hey that looks like a common form of a substitution expression" when you see it in amongst the rest of the script Commented Sep 3, 2016 at 7:10
  • @MikeWarren Yes, I just added code to do the substitution this way for all the shell variables that printenv shows (which is all the exported variables). Commented Sep 3, 2016 at 7:34