<?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 Compressing files with script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923219#M495271</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following script:&lt;/P&gt;&lt;PRE&gt;for files in `ls -lrt | grep -i 'Dec' | awk '{print $9}'`
do
gzip $files
done&lt;/PRE&gt;&lt;P&gt;But I would like also to includes more months, like Jan, Feb and Mar. Can I use "&amp;amp;&amp;amp;" between month&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2016 09:37:51 GMT</pubDate>
    <dc:creator>NDO</dc:creator>
    <dc:date>2016-12-05T09:37:51Z</dc:date>
    <item>
      <title>Compressing files with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923219#M495271</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following script:&lt;/P&gt;&lt;PRE&gt;for files in `ls -lrt | grep -i 'Dec' | awk '{print $9}'`
do
gzip $files
done&lt;/PRE&gt;&lt;P&gt;But I would like also to includes more months, like Jan, Feb and Mar. Can I use "&amp;amp;&amp;amp;" between month&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 09:37:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923219#M495271</guid>
      <dc:creator>NDO</dc:creator>
      <dc:date>2016-12-05T09:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compressing files with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923297#M495272</link>
      <description>&lt;P&gt;&amp;gt; I have the following script:&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; for files in `ls -lrt | grep -i 'Dec' | awk '{print $9}'`&lt;BR /&gt;&amp;gt; [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Not a reliable method, I claim.&lt;/P&gt;&lt;P&gt;mba$ ls -l *.txt | grep -i 'Jan' | awk '{print $9}'&lt;BR /&gt;janfebmaraprmayjun.txt&lt;/P&gt;&lt;P&gt;mba$ ls -l *.txt | grep -i 'Jan'&lt;BR /&gt;-rw-r--r-- 1 sms staff 5 Dec 5 07:58 janfebmaraprmayjun.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Removing the "-i" might help a little, and adding spaces to your&lt;BR /&gt;search string might help more, but it's still not a reliable method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; "find" has options to let the user specify date-time bounds, which is&lt;BR /&gt;generally more reliable than parsing "ls" output -- seldom an easy task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; man find&lt;/P&gt;&lt;P&gt;A search of this forum (or the Web) should find many examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; With "find", you could also specify things like, say:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! -name '*.gz'&lt;BR /&gt;to avoid trying to compress already-compressed files.&lt;/P&gt;&lt;P&gt;&amp;gt; But I would like also to includes more months, like Jan, Feb and Mar.&lt;BR /&gt;&amp;gt; Can I use "&amp;amp;&amp;amp;" between month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If you insist on doing things that way, then "egrep" allows "extended&lt;BR /&gt;regular expressions (EREs)."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; man egrep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; You seem to want an OR condition. For example:&lt;/P&gt;&lt;P&gt;mba$ ls -l *.txt | egrep ' Mar | Jun | Oct '&lt;BR /&gt;-rw-r--r-- 1 sms staff 1172 Oct 18 2015 iv.txt&lt;BR /&gt;-rw-r--r-- 1 sms staff 1167 Mar 29 2016 iv2.txt&lt;BR /&gt;-rw-r--r--@ 1 sms staff 902 Jun 25 2015 ports.txt&lt;BR /&gt;-rw-r--r-- 1 sms staff 2169 Jun 19 2015 vim.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; But it's still a lame method.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 14:27:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923297#M495272</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-12-05T14:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compressing files with script (filter by months)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923404#M495273</link>
      <description>&lt;P&gt;&amp;gt;Can I use "&amp;amp;&amp;amp;" between month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course not.&amp;nbsp; You need to use the computer science OR, not AND.&amp;nbsp; :-)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same cautions that Steven gave about finding months in the the names of files or user/groups.&lt;/P&gt;&lt;P&gt;Also, there is no need to use -tr, since the gzip order doesn't really matter.&lt;/P&gt;&lt;P&gt;Instead of using the egrep hammer, you can use grep with multiple -e:&lt;/P&gt;&lt;P&gt;for files in $(ll | grep -e Jan -e Feb -e Mar -e Dec -e&amp;nbsp; | awk '{print $9}'); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or do the filter in awk and check the Month field:&lt;/P&gt;&lt;P&gt;for files in $(ll | awk '$6 ~ "Jan|Feb|Mar|Dec" {print $9}'); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; "find" has options to let the user specify date-time bounds, which is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which would only work for one year at a time, not all Dec files, of course depending on how many predicates you add to find(1).&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 19:44:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923404#M495273</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2016-12-05T19:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compressing files with script (filter by months)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923443#M495274</link>
      <description>&lt;P&gt;&amp;gt; Also, there is no need to use -tr, [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Yup.&lt;/P&gt;&lt;P&gt;&amp;gt; [...] you can use grep with multiple -e:&lt;BR /&gt;&amp;gt; for files in $(ll | grep -e Jan -e Feb -e Mar -e Dec -e | [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Including spaces would still help here: -e ' Jan '&lt;/P&gt;&lt;P&gt;&amp;gt; &amp;gt; "find" has options to let the user specify date-time bounds, [...]&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; Which would only work for one year at a time, not all Dec files, of&lt;BR /&gt;&amp;gt; course depending on how many predicates you add to find(1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Yup.&lt;/P&gt;&lt;P&gt;&amp;gt; I have the following script:&lt;BR /&gt;&amp;gt; [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; As usual, this may reveal many of the author's poor implementation&lt;BR /&gt;decisions, but it does little to reveal the original intent, that is,&lt;BR /&gt;the actual problem to be solved.&amp;nbsp; Advice on how better to grip a wrench&lt;BR /&gt;may help, but, when your actual goal is driving a nail, a better answer&lt;BR /&gt;may involve a hammer, rather than any advice involving the original&lt;BR /&gt;wrench.&amp;nbsp; If you ask about the wrench, and fail to mention the nail, then&lt;BR /&gt;you can expect sub-ideal advice.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 22:24:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923443#M495274</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-12-05T22:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Compressing files with script (filter by months)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923510#M495275</link>
      <description>&lt;P&gt;Thank you very much for the advice&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 05:58:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6923510#M495275</guid>
      <dc:creator>NDO</dc:creator>
      <dc:date>2016-12-06T05:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compressing files with script (filter by months)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6924922#M495276</link>
      <description>&lt;P&gt;&amp;gt;when your actual goal is driving a nail&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you probably want a screwdriver.&lt;/P&gt;&lt;P&gt;After all, when everything looks like a screw, you tend to use a screwdriver.&amp;nbsp; :-)&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 07:46:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compressing-files-with-script/m-p/6924922#M495276</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2016-12-11T07:46:37Z</dc:date>
    </item>
  </channel>
</rss>

