<?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: elif loop help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054161#M93620</link>
    <description>You shouldn't be using awk.  And you need pattern matching in your ifs:&lt;BR /&gt;for COMPRESSED in $(&amp;lt; list); do&lt;BR /&gt;&lt;BR /&gt;if [[ $COMPRESSED = *.Z ]]; then&lt;BR /&gt;...&lt;BR /&gt;elif [[ $COMPRESSED = *.gz ]]; then&lt;BR /&gt;...&lt;BR /&gt;fi&lt;BR /&gt;done</description>
    <pubDate>Thu, 21 Jun 2007 03:29:54 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-06-21T03:29:54Z</dc:date>
    <item>
      <title>elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054160#M93619</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;I am trying to list files in a directory and if they are *.Z then uncompress or if they are *.gz then gunzip however the sytax I run will uncompress the *.Z files but error on the *.gz files, here is my syntax:&lt;BR /&gt;&lt;BR /&gt;for COMPRESSED in `awk '{print $1}' list`&lt;BR /&gt;do&lt;BR /&gt;if [ -f *.Z ] ; then&lt;BR /&gt;echo "uncompressing $COMPRESSED"&lt;BR /&gt;uncompress $COMPRESSED&lt;BR /&gt;elif [ -f *.gz ] ; then&lt;BR /&gt;echo "uncompressing gzipped $COMPRESSED"&lt;BR /&gt;gunzip $COMPRESSED&lt;BR /&gt;else&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;any help would be greatly appreciated or another solution?&lt;BR /&gt;&lt;BR /&gt;Please note that there thousands of files and running 2 find commands would put additional load to the server.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Thu, 21 Jun 2007 03:19:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054160#M93619</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-06-21T03:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054161#M93620</link>
      <description>You shouldn't be using awk.  And you need pattern matching in your ifs:&lt;BR /&gt;for COMPRESSED in $(&amp;lt; list); do&lt;BR /&gt;&lt;BR /&gt;if [[ $COMPRESSED = *.Z ]]; then&lt;BR /&gt;...&lt;BR /&gt;elif [[ $COMPRESSED = *.gz ]]; then&lt;BR /&gt;...&lt;BR /&gt;fi&lt;BR /&gt;done</description>
      <pubDate>Thu, 21 Jun 2007 03:29:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054161#M93620</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-21T03:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054162#M93621</link>
      <description>&amp;gt;Me: You shouldn't be using awk.&lt;BR /&gt;&lt;BR /&gt;Oops, that assumes you only have filename in your file "list" and not other columns you want to ignore.</description>
      <pubDate>Thu, 21 Jun 2007 03:32:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054162#M93621</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-21T03:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054163#M93622</link>
      <description>Thanks Dennis,&lt;BR /&gt;&lt;BR /&gt;yes the list file has 3 fields so awk would work however I will try you example with the while loop ie:&lt;BR /&gt;&lt;BR /&gt;while read FILE DATE YEAR&lt;BR /&gt;do&lt;BR /&gt;if [[ FILE = *.Z ]] ; then&lt;BR /&gt;etc&lt;BR /&gt;etc&lt;BR /&gt;done &amp;lt; list&lt;BR /&gt;&lt;BR /&gt;will let you know how I get on&lt;BR /&gt;&lt;BR /&gt;cheers &lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 21 Jun 2007 03:40:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054163#M93622</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-06-21T03:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054164#M93623</link>
      <description>again thankyou&lt;BR /&gt;&lt;BR /&gt;works a treat and picked up something new:&lt;BR /&gt;&lt;BR /&gt;for files in $(&lt;LIST&gt;&lt;/LIST&gt;etc&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Thu, 21 Jun 2007 03:46:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054164#M93623</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-06-21T03:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054165#M93624</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;if think you want to test $COMPRESSED&lt;BR /&gt;either [ -f $COMPRESSED ] &lt;BR /&gt;if $COMPRESSED is the filename including the postfix .Z (.gz)&lt;BR /&gt;or [ -f ${COMPRESSED}.Z ]&lt;BR /&gt;if $COMPRESSED does not have the .Z&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Jun 2007 03:49:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054165#M93624</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2007-06-21T03:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054166#M93625</link>
      <description>&lt;!--!*#--&gt;If you have lots of pattern matching, you can use a case:&lt;BR /&gt;for COMPRESSED in ...; do&lt;BR /&gt;case $COMPRESSED in&lt;BR /&gt;*.Z) echo "uncompressing $COMPRESSED"&lt;BR /&gt;     ;;&lt;BR /&gt;*.gz|*.tgz) echo "uncompressing gzipped $COMPRESSED"&lt;BR /&gt;     ;;&lt;BR /&gt;*)   echo "not one of those guys"&lt;BR /&gt;     ;;&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I used "|" above to allow both patterns.</description>
      <pubDate>Thu, 21 Jun 2007 04:10:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054166#M93625</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-21T04:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054167#M93626</link>
      <description>ok nice one,&lt;BR /&gt;&lt;BR /&gt;I like that as it appears to be very effiecient.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Jun 2007 05:02:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054167#M93626</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-06-21T05:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: elif loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054168#M93627</link>
      <description>ty</description>
      <pubDate>Thu, 21 Jun 2007 05:03:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/elif-loop-help/m-p/5054168#M93627</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-06-21T05:03:23Z</dc:date>
    </item>
  </channel>
</rss>

