<?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: awk help PLEASE in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493129#M704697</link>
    <description>Not there... The line&lt;BR /&gt;  while ("ls /Backups" | getline fl)&lt;BR /&gt;ONLY happens one time for each input file.  The problem is when there is more than one line in an input file.&lt;BR /&gt;&lt;BR /&gt;The actual error that I'm trying to avoid is on system mkdir command.  Although it works without displaying an error, I'm not too thrilled with &lt;BR /&gt;  system("mkdir /Backups/" $1 " 2&amp;gt;/dev/null")&lt;BR /&gt;</description>
    <pubDate>Thu, 24 Feb 2005 18:17:39 GMT</pubDate>
    <dc:creator>David Gwin_1</dc:creator>
    <dc:date>2005-02-24T18:17:39Z</dc:date>
    <item>
      <title>awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493127#M704695</link>
      <description>You know... I THOUGHT that I was pretty good at programming in awk until THIS!!!  And maybe I just don't know the right function.&lt;BR /&gt;&lt;BR /&gt;Anyhow, all I'm trying to do is determine if a file already exists.  I read that the "ls /Backups" command (or any getline cmd) will only execute ONE time (I was thinking that it would execute once for each input record, WRONG).&lt;BR /&gt;&lt;BR /&gt;My real question is... How do i determine if a file already exist without getting an error or system error.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BEGIN { }&lt;BR /&gt;{&lt;BR /&gt;      x=0&lt;BR /&gt;      while ("ls /Backups" | getline fl)&lt;BR /&gt;         {&lt;BR /&gt;         print fl " == " $1 " and x is " x &lt;BR /&gt;         if ( test fl == $1 ) x=1&lt;BR /&gt;         }&lt;BR /&gt;      if (x == 0)&lt;BR /&gt;         {&lt;BR /&gt;         print x &lt;BR /&gt;         system("mkdir /Backups/" $1 )&lt;BR /&gt;         }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;THANK YOU&lt;BR /&gt;David</description>
      <pubDate>Thu, 24 Feb 2005 17:45:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493127#M704695</guid>
      <dc:creator>David Gwin_1</dc:creator>
      <dc:date>2005-02-24T17:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493128#M704696</link>
      <description>Use a variation on this theme (the key is redirecting stderr so you don'tt see any errors):&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;  x = 0&lt;BR /&gt;  while ((x &amp;lt; 1) &amp;amp;&amp;amp; "ls /Backups 2&amp;gt;/dev/null" | getline fl)&lt;BR /&gt;    {&lt;BR /&gt;      ++x&lt;BR /&gt;    }&lt;BR /&gt;  if (x &amp;lt; 1)&lt;BR /&gt;    {&lt;BR /&gt;      print "File not found"&lt;BR /&gt;    }&lt;BR /&gt;  else&lt;BR /&gt;    {&lt;BR /&gt;      print "File found"&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 17:57:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493128#M704696</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-24T17:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493129#M704697</link>
      <description>Not there... The line&lt;BR /&gt;  while ("ls /Backups" | getline fl)&lt;BR /&gt;ONLY happens one time for each input file.  The problem is when there is more than one line in an input file.&lt;BR /&gt;&lt;BR /&gt;The actual error that I'm trying to avoid is on system mkdir command.  Although it works without displaying an error, I'm not too thrilled with &lt;BR /&gt;  system("mkdir /Backups/" $1 " 2&amp;gt;/dev/null")&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 18:17:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493129#M704697</guid>
      <dc:creator>David Gwin_1</dc:creator>
      <dc:date>2005-02-24T18:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493130#M704698</link>
      <description>to test for the directory&lt;BR /&gt;&lt;BR /&gt;you could do:&lt;BR /&gt;&lt;BR /&gt;a=system("test -d /tmp");&lt;BR /&gt;&lt;BR /&gt;a=0 if there is a directory /tmp&lt;BR /&gt;a!=0 if there isn't</description>
      <pubDate>Thu, 24 Feb 2005 18:33:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493130#M704698</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-02-24T18:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493131#M704699</link>
      <description>and to read everyline for every line of input, do something like this:&lt;BR /&gt;&lt;BR /&gt;while (( "ls /tmp" | getline def ) &amp;gt; 0 ) {&lt;BR /&gt;print def;&lt;BR /&gt;}&lt;BR /&gt;close("ls /tmp");&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 18:36:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493131#M704699</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-02-24T18:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493132#M704700</link>
      <description>I perl you'd do somehting like:&lt;BR /&gt;&lt;BR /&gt;perl -e '$dir = "/Backups/$name"; mkdir ($dir,0777) unless (-d $dir)'&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 23:28:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493132#M704700</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-02-24T23:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493133#M704701</link>
      <description>To make this simply with shell we can do as,&lt;BR /&gt;&lt;BR /&gt;[[ ! -d muthu ]] &amp;amp;&amp;amp; mkdir muthu&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;To do with AWK using your style then,&lt;BR /&gt;&lt;BR /&gt;--- test. awk ---&lt;BR /&gt;BEGIN { }&lt;BR /&gt;{&lt;BR /&gt;x=0&lt;BR /&gt;while ("[[ -d muthu ]] &amp;amp;&amp;amp; ls muthu"| getline fl)&lt;BR /&gt;{&lt;BR /&gt;print fl " == " $1 " and x is " x&lt;BR /&gt;if ( test fl == $1 ) x=1&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;if (x == 0)&lt;BR /&gt;{&lt;BR /&gt;print x&lt;BR /&gt;system("mkdir muthu")&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# awk -f test.awk&lt;BR /&gt;0&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;That is all.&lt;BR /&gt;&lt;BR /&gt;Problem you had,&lt;BR /&gt;&lt;BR /&gt;1. Try to do check and create new directory in the END part only.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Feb 2005 02:21:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493133#M704701</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-02-25T02:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: awk help PLEASE</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493134#M704702</link>
      <description>Why be AWKward? ksh will do it:&lt;BR /&gt;&lt;BR /&gt;if [[ -d /Backups ]]&lt;BR /&gt;then&lt;BR /&gt;echo "Directory /Backups exists"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [[ -a /Backups/filename ]]&lt;BR /&gt;then&lt;BR /&gt;echo "filename exists"&lt;BR /&gt;fi</description>
      <pubDate>Fri, 25 Feb 2005 04:42:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-please/m-p/3493134#M704702</guid>
      <dc:creator>Gordon  Morrison</dc:creator>
      <dc:date>2005-02-25T04:42:39Z</dc:date>
    </item>
  </channel>
</rss>

