<?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 assistance! Please in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600101#M855562</link>
    <description>You are good at giving awsome points too.. Thanks.&lt;BR /&gt;&lt;BR /&gt;Now coming to your while statement, you are declaring the $ variable as "server" in the while loop but you are using "Server" in the subsequent lines. Case does matter in UNIX. So either replace "server" with Server or vice versa.&lt;BR /&gt;&lt;BR /&gt;And it is a good practice to keep the $ variables in {}s if they are followed by extra characters. Like ${Server}.tar. It doesnt' matter much here but it does in some places.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Wed, 24 Oct 2001 00:25:56 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2001-10-24T00:25:56Z</dc:date>
    <item>
      <title>AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600099#M855560</link>
      <description>Yesterday I asked for some awk assistance and bascially if there was another way to untar a bunch of files and I did get some awesome replies.  But, yet another question ( &lt;BR /&gt;second part of the script) that I am stuck on, I have read manuals and I guess they are just to vague for me.  PROBLEM:  I am trying to untar a ton of baby tar balls that are identified (named) by their node name (we have over 500 nodes).  I figured awk was the best way to do this, I did a 'ls -l' on the dir that the mother tar ball unloaded the baby tar balls into.  The mother tar ball (1st part of script) created baby tar balls into another dir.  I output the 'ls -l' to a file called 'babytar' and I awk the 'babytar' file and print on the 9th column which gives me the node name that I need to identify the baby tar balls by.  I am getting an error on 'while' statement and the 'do' statement, if there is anybody that can spot what I am missing, again, I will CROWN THEE!  &lt;BR /&gt;--------------Cut and Paste of Script----------&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;cd /home/s1perf/test_dir/test_dump&lt;BR /&gt;ls -l &amp;gt; /home/s1perf/test_dir/babytar&lt;BR /&gt;awk '{print $9}' /home/s1perf/test_dir/babytar | sort | while read server ; do&lt;BR /&gt;  if [[ -f $DATA/$Server.tar ]] ; then&lt;BR /&gt;  yes| tar xvf $Server.tar&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;chmod 777 *&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Oct 2001 23:23:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600099#M855560</guid>
      <dc:creator>Chris Tijerina_2</dc:creator>
      <dc:date>2001-10-23T23:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600100#M855561</link>
      <description>upcase the "S" in server for the while ... do construct:&lt;BR /&gt;&lt;BR /&gt;while read Server ; do&lt;BR /&gt;&lt;BR /&gt;or change your other references of $Server with $server</description>
      <pubDate>Tue, 23 Oct 2001 23:51:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600100#M855561</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-10-23T23:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600101#M855562</link>
      <description>You are good at giving awsome points too.. Thanks.&lt;BR /&gt;&lt;BR /&gt;Now coming to your while statement, you are declaring the $ variable as "server" in the while loop but you are using "Server" in the subsequent lines. Case does matter in UNIX. So either replace "server" with Server or vice versa.&lt;BR /&gt;&lt;BR /&gt;And it is a good practice to keep the $ variables in {}s if they are followed by extra characters. Like ${Server}.tar. It doesnt' matter much here but it does in some places.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 24 Oct 2001 00:25:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600101#M855562</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-24T00:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600102#M855563</link>
      <description>BTW.. I like your affinity towards "awk".&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 24 Oct 2001 00:28:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600102#M855563</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-24T00:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600103#M855564</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;   There seems to be a mismatch in the ""Server.tar""&lt;BR /&gt;and "'server"'  in your script.  Also, make sure&lt;BR /&gt;the DATA variable is defined.&lt;BR /&gt;&lt;BR /&gt;-raj</description>
      <pubDate>Wed, 24 Oct 2001 00:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600103#M855564</guid>
      <dc:creator>Roger Baptiste</dc:creator>
      <dc:date>2001-10-24T00:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600104#M855565</link>
      <description>here are some comments:&lt;BR /&gt;&lt;BR /&gt;cd /home/s1perf/test_dir/test_dump &lt;BR /&gt;ls -l &amp;gt; /home/s1perf/test_dir/babytar &lt;BR /&gt;awk '{print $9}' /home/s1perf/test_dir/babytar &lt;BR /&gt;&lt;BR /&gt;change to the above two lines to just:&lt;BR /&gt;ls -d | sort ...&lt;BR /&gt;&lt;BR /&gt;if you really want the results of the "ls" in a file, do:  ls -d | tee yourfilename | sort ...&lt;BR /&gt;&lt;BR /&gt;| sort | while read server ; do &lt;BR /&gt;if [[ -f $DATA/$Server.tar ]] ; then &lt;BR /&gt;&lt;BR /&gt;change $Server.tar to ${server}.tar&lt;BR /&gt;the {} isn't really necessary, but the S-&amp;gt;s is&lt;BR /&gt;$DATA???  where is that defined?&lt;BR /&gt;&lt;BR /&gt;yes| tar xvf $Server.tar &lt;BR /&gt;&lt;BR /&gt;change $Server.tar to ${server}.tar&lt;BR /&gt;the {} isn't really necessary, but the S-&amp;gt;s is&lt;BR /&gt;&lt;BR /&gt;fi &lt;BR /&gt;done &lt;BR /&gt;chmod 777 * &lt;BR /&gt;&lt;BR /&gt;if you want to change permissions on all the files you just untared, you'll need to add the -R option to the chmod if there are subdirectories&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Oct 2001 00:48:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600104#M855565</guid>
      <dc:creator>Curtis Larson_1</dc:creator>
      <dc:date>2001-10-24T00:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600105#M855566</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;I assume the variable DATA is defined elsewhere, in which case the following should work for you:&lt;BR /&gt;&lt;BR /&gt;========================================&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;cd /home/s1perf/test_dir/test_dump&lt;BR /&gt;ls | while read server ; do&lt;BR /&gt;test -f $DATA/${server}.tar &amp;amp;&amp;amp; yes | tar xvf $DATA/${server}.tar&lt;BR /&gt;done&lt;BR /&gt;chmod 777 *&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;=========================================&lt;BR /&gt;&lt;BR /&gt;Don't forget that 'ls' sorts by default, and even though it outputs to the screen in multi-column format, internally it is one-per-line, so 'ls' on its own is OK.&lt;BR /&gt;&lt;BR /&gt;I've added $DATA in the tar command too, don't know if that's what you want.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Wed, 24 Oct 2001 06:27:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600105#M855566</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-10-24T06:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600106#M855567</link>
      <description>Well, this seems to be quite complex (lots of pipes) ....&lt;BR /&gt;&lt;BR /&gt;"ls -l | awk ..."   vs.   "ls -1"  (one)&lt;BR /&gt;"while read"  vs. "for name in"&lt;BR /&gt;&lt;BR /&gt;This could be a streamlined version&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh &lt;BR /&gt;cd /home/s1perf/test_dir/test_dump &lt;BR /&gt;for name in `ls -1`   # add required sortflag to ls&lt;BR /&gt;do&lt;BR /&gt;  if [[ -f $DATA/$name.tar ]] ; then &lt;BR /&gt;yes| tar xvf $name.tar &lt;BR /&gt;fi &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;The syntax error as already mentioned seems to me the uppercase "S" mismatch in your script.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 24 Oct 2001 06:43:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600106#M855567</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-10-24T06:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600107#M855568</link>
      <description>&lt;BR /&gt;Volker ( and all):&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;`ls -1`  create a new process, and can be changed by * that will be treated on the current shell. &lt;BR /&gt;&lt;BR /&gt;Sort is not needed because you will treat whole directory, and * will show alfa. sorted. &lt;BR /&gt;&lt;BR /&gt;I dont know why that yes.&lt;BR /&gt;&lt;BR /&gt;So my command will be&lt;BR /&gt;for file in */*.tar&lt;BR /&gt;do&lt;BR /&gt;tar xvf  $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;echo */*.tar | xargs -n 1 tar xvf &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Oct 2001 07:42:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600107#M855568</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-10-24T07:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600108#M855569</link>
      <description>Just out of curiosity, why can't we replace the "ls |while read" construct with  "for FILE in *" construct.  The second construct saves on a process and a pipe but does the same thing...i.e.:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cd /home/s1perf/test_dir/test_dump &lt;BR /&gt;                                                     for server in *&lt;BR /&gt;do&lt;BR /&gt;   test -f $DATA/${server}.tar &amp;amp;&amp;amp; yes | tar xvf $DATA/${server}.tar&lt;BR /&gt;done&lt;BR /&gt;chmod 777 *&lt;BR /&gt;exit 0 &lt;BR /&gt;&lt;BR /&gt;-Santosh</description>
      <pubDate>Wed, 24 Oct 2001 08:19:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600108#M855569</guid>
      <dc:creator>Santosh Nair_1</dc:creator>
      <dc:date>2001-10-24T08:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: AWK assistance! Please</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600109#M855570</link>
      <description>Hi folks,&lt;BR /&gt;interesting thread !&lt;BR /&gt;&lt;BR /&gt;Just did some tests on a UX 11 with root and other users in sh and csh.&lt;BR /&gt;&lt;BR /&gt;Now did you expect, that &lt;BR /&gt;&lt;BR /&gt;ls -1&lt;BR /&gt;is diffrent from&lt;BR /&gt;ls -1 *&lt;BR /&gt;&lt;BR /&gt;???&lt;BR /&gt;&lt;BR /&gt;OK, no suprise:&lt;BR /&gt;ls -1 * goes into directories and lists what's in in addition. This can be caught by "ls -1d".&lt;BR /&gt;BUT, suprise:&lt;BR /&gt;as root in sh, 'ls -1' lists hidden files while 'ls -1d *' does not.&lt;BR /&gt;&lt;BR /&gt;Which is diffrent for a common user in csh.&lt;BR /&gt;&lt;BR /&gt;Hey Chris, however you solve it, I recommend to verify that whatever wildcard you choose, it meets what you want.&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;Volker&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Oct 2001 10:01:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-assistance-please/m-p/2600109#M855570</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-10-24T10:01:04Z</dc:date>
    </item>
  </channel>
</rss>

