<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variables, using $ and ${ }_&amp;quot;other words&amp;quot; in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804477#M267151</link>
    <description>If you get into the habit of enclosing all shell variables in {}'s even in the cases where they are not absolutely required, you will avoid many problems. I always prefer code (even in my head) that does not branch.</description>
    <pubDate>Mon, 12 Jun 2006 14:23:29 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2006-06-12T14:23:29Z</dc:date>
    <item>
      <title>Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804468#M267142</link>
      <description>Hi ..&lt;BR /&gt;I have a value kept in $file_galaxy variable but i need to use same variable with date format as follows: $file_galaxy_`date +"%Y%m%d"&lt;BR /&gt;&lt;BR /&gt;but it does not work !!!!&lt;BR /&gt;i have tested:&lt;BR /&gt;$file_galaxy_`date +"%Y%m%d"&lt;BR /&gt;$(file_galaxy)_`date +"%Y%m%d"&lt;BR /&gt;${file_galaxy}_`date +"%Y%m%d"&lt;BR /&gt;`file_galaxy`_`date +"%Y%m%d"&lt;BR /&gt;&lt;BR /&gt;and any of above shown work !!!!&lt;BR /&gt;&lt;BR /&gt;please help 1!!&lt;BR /&gt;I'm using sh and ksh ...&lt;BR /&gt;&lt;BR /&gt;I only obtain: _20060612 or 20060612&lt;BR /&gt;thanks ....&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 13:57:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804468#M267142</guid>
      <dc:creator>Manuales</dc:creator>
      <dc:date>2006-06-12T13:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804469#M267143</link>
      <description>It looks like you've got your back ticks reversed to forward ticks.  Try &lt;BR /&gt;$file_galaxy_`date +"%Y%m%d`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 12 Jun 2006 14:03:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804469#M267143</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-06-12T14:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804470#M267144</link>
      <description>While I was waiting for the submit it occured to me that the "_" character is probably not part of the original variable file_galaxy.  Try &lt;BR /&gt;&lt;BR /&gt;${file_galaxy}_`date +"%Y%m%d`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 12 Jun 2006 14:05:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804470#M267144</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-06-12T14:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804471#M267145</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;sorry i forget to put "`" at the end of the variables:&lt;BR /&gt;&lt;BR /&gt;$file_galaxy_`date +"%Y%m%d"`&lt;BR /&gt;$(file_galaxy)_`date +"%Y%m%d"`&lt;BR /&gt;${file_galaxy}_`date +"%Y%m%d"`&lt;BR /&gt;`file_galaxy`_`date +"%Y%m%d"`&lt;BR /&gt;&lt;BR /&gt;but any way they do not work ..!!!! :'(&lt;BR /&gt;&lt;BR /&gt;help !!!&lt;BR /&gt;SOS !!!!&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:08:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804471#M267145</guid>
      <dc:creator>Manuales</dc:creator>
      <dc:date>2006-06-12T14:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804472#M267146</link>
      <description>the syntax should be...&lt;BR /&gt;&lt;BR /&gt;# echo ${file_galaxy}_`date +"%Y%m%d"`&lt;BR /&gt;or&lt;BR /&gt;# echo ${file_galaxy}_$(date +"%Y%m%d")&lt;BR /&gt;&lt;BR /&gt;in each of your cases, you are missing the variable-delimiting braces, ${file_galaxy}, and the terminating single-tick for command substitution i.e. `date +"%Y%m%d"`&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Mon, 12 Jun 2006 14:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804472#M267146</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-06-12T14:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804473#M267147</link>
      <description>Not sure why your third example did not work, unless you forgot to close the single quote.&lt;BR /&gt;&lt;BR /&gt;I wrote:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;file_galaxy="testfile"&lt;BR /&gt;&lt;BR /&gt;print $file_galaxy&lt;BR /&gt;&lt;BR /&gt;date=`date +"%Y%m%d"`&lt;BR /&gt;&lt;BR /&gt;print $date&lt;BR /&gt;&lt;BR /&gt;print ${file_galaxy}_`date +"%Y%m%d"`&lt;BR /&gt;&lt;BR /&gt;and got:&lt;BR /&gt;./junk.sh&lt;BR /&gt;testfile&lt;BR /&gt;20060612&lt;BR /&gt;testfile_20060612&lt;BR /&gt;&lt;BR /&gt;when run.&lt;BR /&gt;I used 11.11 for the test. &lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:11:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804473#M267147</guid>
      <dc:creator>Ken Grabowski</dc:creator>
      <dc:date>2006-06-12T14:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804474#M267148</link>
      <description>Try ${file_galaxy}_`date +"%Y%m%d"`&lt;BR /&gt;&lt;BR /&gt;All of your examples are missing the final&lt;BR /&gt;backtick (`).  Also,&lt;BR /&gt;&lt;BR /&gt;Example 1 doesn't work because the shell&lt;BR /&gt;thinks the second "_" is part of the&lt;BR /&gt;variable name.&lt;BR /&gt;&lt;BR /&gt;Example 2 doesn't work because $(...) runs&lt;BR /&gt;the ... as a command.&lt;BR /&gt;&lt;BR /&gt;Example 4 doesn't work because `...` runs&lt;BR /&gt;the ... as a command.&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:13:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804474#M267148</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2006-06-12T14:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804475#M267149</link>
      <description>Do something like this:&lt;BR /&gt;&lt;BR /&gt;NEWVAR=${file_galaxy}_$(date '+%Y%m%d')&lt;BR /&gt;&lt;BR /&gt;echo "NEWVAR = \"${NEWVAR}\""&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:13:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804475#M267149</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-06-12T14:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804476#M267150</link>
      <description>Hi Manuales:&lt;BR /&gt;&lt;BR /&gt;These are ambiguous variable names.  Is the underscore part of the name or is it just another part of the overall interpreted string?&lt;BR /&gt;&lt;BR /&gt;Consider the first one: $file_galaxy_`date +"%Y%m%d"&lt;BR /&gt;&lt;BR /&gt;If I add the closing backtick:&lt;BR /&gt;&lt;BR /&gt;# echo $file_galaxy_`date +"%Y%m%d"`&lt;BR /&gt;sh: file_galaxy_: Parameter not set.&lt;BR /&gt;&lt;BR /&gt;Thus, the shell "thinks" that the variable to be interpreted is named "file_galaxy_".  Is that what you meant, or did you mean "file_galaxy"?&lt;BR /&gt;&lt;BR /&gt;# echo ${file_galaxy}_`date +"%Y%m%d"`&lt;BR /&gt;sh: file_galaxy: Parameter not set. &lt;BR /&gt;&lt;BR /&gt;NOTE that the second time I enclosed the variable name in braces -- {} &lt;BR /&gt;&lt;BR /&gt;This informs the shell of the exact variable name without ambiguity.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 12 Jun 2006 14:20:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804476#M267150</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-12T14:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804477#M267151</link>
      <description>If you get into the habit of enclosing all shell variables in {}'s even in the cases where they are not absolutely required, you will avoid many problems. I always prefer code (even in my head) that does not branch.</description>
      <pubDate>Mon, 12 Jun 2006 14:23:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804477#M267151</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-06-12T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804478#M267152</link>
      <description>THANKS TO ALL:&lt;BR /&gt;It worked with this one:&lt;BR /&gt;&lt;BR /&gt;${file_galaxy}_$(date +"%Y%m%d")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i do not know why this do not work with "`" at the beggining and the end of the variable ..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ANY WAY THANKS TO ALL FRIENDS Â°!!!!!!</description>
      <pubDate>Mon, 12 Jun 2006 14:26:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804478#M267152</guid>
      <dc:creator>Manuales</dc:creator>
      <dc:date>2006-06-12T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804479#M267153</link>
      <description>And if you check the man pages for ksh and the HP POSIX shell sh-posix, you'll see that backticks (reverse apostrophes or grave accents) are deprecated (or not recommended). There several reasons:&lt;BR /&gt; &lt;BR /&gt;1. The back tick ` looks too much like a forward tick ' (apostrophe)&lt;BR /&gt; &lt;BR /&gt;2. Back ticks can easily be missed in printed text, especially on a fax.&lt;BR /&gt; &lt;BR /&gt;3. Back ticks cannot be nested.&lt;BR /&gt; &lt;BR /&gt;The preferred coding is to use $(commands). Thde $() construct can easily be nested, something like this:&lt;BR /&gt; &lt;BR /&gt;# lvdisplay $(bdf /tmp|tail -1| cut -f1 -d\ )|grep "^LV"       &lt;BR /&gt;LV Name                     /dev/vg00/lvol4&lt;BR /&gt;LV Permission               read/write   &lt;BR /&gt;LV Status                   available/syncd           &lt;BR /&gt;LV Size (Mbytes)            80 &lt;BR /&gt; &lt;BR /&gt;This command finds the mountpoint source for /tmp using bdf, then extracts it with cut, uses the value as an argument to lvdisplay and grep grabs all the LV lines. Not possible with backticks.</description>
      <pubDate>Mon, 12 Jun 2006 17:35:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804479#M267153</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-06-12T17:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Variables, using $ and ${ }_"other words"</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804480#M267154</link>
      <description>Ooops, I showed my interim tests. Here was the desired result:&lt;BR /&gt; &lt;BR /&gt;echo $(lvdisplay $(bdf /tmp|tail -1| cut -f1 -d\ )|grep "^LV Size")|awk '{print $NF}'&lt;BR /&gt; &lt;BR /&gt;which shows the Mbyte size for /tmp. The LV Size line contains the Mbytes number at the end. (somewhat impractical example but shows how $(...$(...)) can be nested.</description>
      <pubDate>Mon, 12 Jun 2006 17:42:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variables-using-and-quot-other-words-quot/m-p/3804480#M267154</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-06-12T17:42:27Z</dc:date>
    </item>
  </channel>
</rss>

