<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Linux on DevOps, Productivity, Career // etogeek blog</title>
    <link>https://etogeek.dev/en/tags/linux/</link>
    <description>Recent content in Linux on DevOps, Productivity, Career // etogeek blog</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 28 Jan 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://etogeek.dev/en/tags/linux/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Difference between $VAR and ${VAR}?</title>
      <link>https://etogeek.dev/en/posts/shell-variables/</link>
      <pubDate>Sun, 28 Jan 2024 00:00:00 +0000</pubDate>
      <guid>https://etogeek.dev/en/posts/shell-variables/</guid>
      <description>&lt;p&gt;This is really a frequent question. I&amp;rsquo;m explaining in addition to the &lt;a href=&#34;https://t.me/etogeek/224&#34;   target=&#34;_blank&#34;&gt;&#xA;    post&lt;/a&gt;(sorry, it is not translated yet) about variable substitution in a file.&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s no rocket science here, and the difference only lies in how the command interpreter (Bash, zsh, sh, thousands of them) determines the boundaries of the variable name:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;$VAR&lt;/code&gt; — works well when the variable name is separated from other text by unused symbols, such as a space, or a backslash. But if we insert the variable into a word, it will be interpreted incorrectly:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;VAR&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;eto&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;$VAR&lt;/span&gt;      &lt;span class=&#34;c1&#34;&gt;# Will output eto&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;$VARgeek&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;# Will output the value of VARgeek, if it exists, otherwise — empty&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;${VAR}&lt;/code&gt; — more reliable. Helps to accurately separate the variable name from other text:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;VAR&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;eto&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;VAR&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;     &lt;span class=&#34;c1&#34;&gt;# Will output eto&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;VAR&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;geek &lt;span class=&#34;c1&#34;&gt;# Will output etogeek&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
  </channel>
</rss>