<?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: variable in if in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179847#M91032</link>
    <description>I know&lt;BR /&gt;&lt;BR /&gt;I just thought that option is available...but I forgot it...I just want to know it for memory refresh purple&lt;BR /&gt;&lt;BR /&gt;but, thanks for your help anyway</description>
    <pubDate>Tue, 15 Apr 2008 00:34:30 GMT</pubDate>
    <dc:creator>Gemini_2</dc:creator>
    <dc:date>2008-04-15T00:34:30Z</dc:date>
    <item>
      <title>variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179839#M91024</link>
      <description>I would like to  change the following two statements into one.&lt;BR /&gt;&lt;BR /&gt;"list=$(ls -1 $xturns/tur*)&lt;BR /&gt;if [ "$list" ];then"&lt;BR /&gt;&lt;BR /&gt;how can I do that?&lt;BR /&gt;&lt;BR /&gt;i tried &lt;BR /&gt;if [ $list=$(ls -1 $xturns/tur*) ]; then&lt;BR /&gt;&lt;BR /&gt;but...it doesnt work...&lt;BR /&gt;&lt;BR /&gt;for shell script..please advise</description>
      <pubDate>Mon, 14 Apr 2008 21:50:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179839#M91024</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-14T21:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179840#M91025</link>
      <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;# LIST=$(ls -1 /tmp/tur* 2&amp;gt;/dev/null||echo "empty")&lt;BR /&gt;&lt;BR /&gt;# echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;...would return a list of files or the word "empty"&lt;BR /&gt;&lt;BR /&gt;Is that your objective?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 14 Apr 2008 22:42:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179840#M91025</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-14T22:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179841#M91026</link>
      <description>not quite.&lt;BR /&gt;&lt;BR /&gt;I just want to condense two statements into one in the if statement. can that be done?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Apr 2008 22:44:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179841#M91026</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-14T22:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179842#M91027</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Again, I'm not sure of your objective, but:&lt;BR /&gt;&lt;BR /&gt;if  [ -z "$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)" ]; then&lt;BR /&gt;echo "empty"&lt;BR /&gt;    else&lt;BR /&gt;echo "ok"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...Note that no variable is necessary for capturing the list.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 14 Apr 2008 22:57:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179842#M91027</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-14T22:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179843#M91028</link>
      <description>ah, you are right.. I didnt make myself clear. I left one important part. my bad.&lt;BR /&gt;&lt;BR /&gt;use your example&lt;BR /&gt;&lt;BR /&gt;if  [ -z "$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)" ]; then&lt;BR /&gt;echo "empty"&lt;BR /&gt;    else&lt;BR /&gt;echo "ok"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;what if i want to echo the result of ls -l? then what do you do&lt;BR /&gt;&lt;BR /&gt;thanks for your patience&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Apr 2008 23:01:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179843#M91028</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-14T23:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179844#M91029</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I think the best we might do is:&lt;BR /&gt;&lt;BR /&gt;# LIST=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)&lt;BR /&gt;# [ -z "${LIST}" ] &amp;amp;&amp;amp; echo "empty" || echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;...yes, that's two statements, but ...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 14 Apr 2008 23:12:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179844#M91029</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-14T23:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179845#M91030</link>
      <description>I was hoping to have something like this&lt;BR /&gt;&lt;BR /&gt; [ -z "${LIST}=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)" ] &amp;amp;&amp;amp; echo "empty" || echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;but, i know my syntax is not quite right...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;anyway..thaks for your help..</description>
      <pubDate>Mon, 14 Apr 2008 23:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179845#M91030</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-14T23:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179846#M91031</link>
      <description>Just so I understand, ...&lt;BR /&gt;&lt;BR /&gt;You have two simple statements which work&lt;BR /&gt;properly, and are easy to understand, and you&lt;BR /&gt;wish to combine them into a single, more&lt;BR /&gt;complex statement because you think that that&lt;BR /&gt;will look better somehow?&lt;BR /&gt;&lt;BR /&gt;Is that the goal here?</description>
      <pubDate>Tue, 15 Apr 2008 00:28:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179846#M91031</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-15T00:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179847#M91032</link>
      <description>I know&lt;BR /&gt;&lt;BR /&gt;I just thought that option is available...but I forgot it...I just want to know it for memory refresh purple&lt;BR /&gt;&lt;BR /&gt;but, thanks for your help anyway</description>
      <pubDate>Tue, 15 Apr 2008 00:34:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179847#M91032</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-15T00:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179848#M91033</link>
      <description>&lt;P&gt;&amp;gt;I would like to change the following two statements into one.&lt;BR /&gt;&lt;BR /&gt;You would do the obvious:&lt;BR /&gt;if [ "$(ls -1 $xturns/tur*)" ]; then&lt;BR /&gt;&lt;BR /&gt;Compare to JRF's solution where -z tests for empty string.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;what if I want to echo the result of ls -l?&lt;BR /&gt;&lt;BR /&gt;As Steven said, why make it harder to understand?&lt;BR /&gt;&lt;BR /&gt;But if you insist, if may be something like:&lt;BR /&gt;[ -z "${LIST:=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)}" ] &amp;amp;&amp;amp; echo "empty" || echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;Note: You would really need to unset LIST to make sure it gets set.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2011 02:01:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179848#M91033</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-17T02:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179849#M91034</link>
      <description>yes, yes, your answer is correct.&lt;BR /&gt;&lt;BR /&gt;it was very closed to what I had, but I placed my quote place wrong.&lt;BR /&gt;&lt;BR /&gt;thanks for your help!&lt;BR /&gt;&lt;BR /&gt;ps: you also dont need the ":=", you only need "="</description>
      <pubDate>Tue, 15 Apr 2008 20:59:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179849#M91034</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-15T20:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179850#M91035</link>
      <description>Hi (again) Gemini:&lt;BR /&gt;&lt;BR /&gt;I too had concocted a solution identical to by Dennis'.  It would seem to be correct (using '=' instead of the ALGOL assignment ':=' operator) and yet failed/fails for me:&lt;BR /&gt;&lt;BR /&gt;# [ -z "${LIST=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null})" ] &amp;amp;&amp;amp; echo "empty" || echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;This does not yield any results for me; rather it gives and empty list.  Comments, gentlemen?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 15 Apr 2008 21:59:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179850#M91035</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-15T21:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179851#M91036</link>
      <description>oh, he had a little typo in his statement..&lt;BR /&gt;I corrected in my script, but I didnt point it out.&lt;BR /&gt;&lt;BR /&gt;this should be right.&lt;BR /&gt;&lt;BR /&gt;[ -z "${LIST=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)}" ] &amp;amp;&amp;amp; echo "empty" || echo ${LIST}</description>
      <pubDate>Tue, 15 Apr 2008 22:20:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179851#M91036</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2008-04-15T22:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179852#M91037</link>
      <description>&lt;P&gt;I made a typo, swap the "}" and ")":&lt;BR /&gt;[ -z "${LIST:=$(ls -1 /tmp/gemini* 2&amp;gt;/dev/null)}" ]&lt;BR /&gt;&lt;BR /&gt;&amp;gt;you also don't need the ":=", you only need "="&lt;BR /&gt;&lt;BR /&gt;Yes, only because $LIST must NOT be set at all.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: This does not yield any results for me; rather it gives and empty list. Comments, gentlemen?&lt;BR /&gt;&lt;BR /&gt;Did you do this as root? You have created a file in /dev: null}&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2011 02:03:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179852#M91037</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-17T02:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: variable in if</title>
      <link>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179853#M91038</link>
      <description>Hi Gemini &amp;amp; Dennis:&lt;BR /&gt;&lt;BR /&gt;Aahhaa!  Yes, OK.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I made a typo, swap the "}" and ")":&lt;BR /&gt;&lt;BR /&gt;Oh, OK, I kept missing that :-{&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: Did you do this as root? You have created a file in /dev: null}&lt;BR /&gt;&lt;BR /&gt;And, again, yes!  I did and I had a file in '/dev/' so named.&lt;BR /&gt;&lt;BR /&gt;Very nice solution, Dennis.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Apr 2008 22:42:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/variable-in-if/m-p/4179853#M91038</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-15T22:42:50Z</dc:date>
    </item>
  </channel>
</rss>

