<?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: sending parameter to awk command (urgent!!!) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954609#M290835</link>
    <description>Osman,&lt;BR /&gt;Hope you are looking for something like this :(This is a nice one. shows filesystems values , if it cross the threshold limit) &lt;BR /&gt;&lt;BR /&gt;bdf | awk 'a[split($5,a,"%")-1]&amp;gt;90'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Raj.</description>
    <pubDate>Fri, 02 Mar 2007 18:16:47 GMT</pubDate>
    <dc:creator>Raj D.</dc:creator>
    <dc:date>2007-03-02T18:16:47Z</dc:date>
    <item>
      <title>sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954599#M290825</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;For example I have a command like&lt;BR /&gt;&lt;BR /&gt;du -x .|awk '{ if($1 &amp;gt; 10) {print}}' as we mentioned the day before.&lt;BR /&gt;&lt;BR /&gt;this command finds all the directories which are largen than 10kb.&lt;BR /&gt;&lt;BR /&gt;I need to change the size everytime I run the program. &lt;BR /&gt;&lt;BR /&gt;for example I run the program as&lt;BR /&gt;./program -D 20&lt;BR /&gt;&lt;BR /&gt;-D stands for the program searches for only directories. I assign this to $1. 20 stands for the size and I assign it to $2.&lt;BR /&gt;&lt;BR /&gt;now, how can I write the du..|awk.. command?&lt;BR /&gt;I tried &lt;BR /&gt;du -x .|awk '{ if($1 &amp;gt; $2) {print}}'&lt;BR /&gt;and &lt;BR /&gt;du -x .|awk '{ if($3 &amp;gt; $2) {print}}' &lt;BR /&gt;&lt;BR /&gt;but it didn't work. (results were not correct) Can anyone help? &lt;BR /&gt;</description>
      <pubDate>Fri, 02 Mar 2007 09:48:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954599#M290825</guid>
      <dc:creator>Osman Yagmurdereli</dc:creator>
      <dc:date>2007-03-02T09:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954600#M290826</link>
      <description>I am not a huge awk monger but i can offer you a different route. You could use the find command.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;#find . -type d -size +500c&lt;BR /&gt;&lt;BR /&gt;this will find print any directory that is greater than 500 bytes. This way you could pass a size in bytes to the script and pass it to the find command. Or find a tool thaat will do size conversions to bytes and then pass that to the find command.</description>
      <pubDate>Fri, 02 Mar 2007 10:00:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954600#M290826</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-03-02T10:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954601#M290827</link>
      <description>Hi Osman,&lt;BR /&gt;&lt;BR /&gt;write this:&lt;BR /&gt;set variable = "your choice"&lt;BR /&gt;du -x .|awk '{ if($1 &amp;gt; '$variable') {print}}'&lt;BR /&gt;Important are the quotings of $variable.&lt;BR /&gt;&lt;BR /&gt;Greetings &lt;BR /&gt;&lt;BR /&gt;Karsten</description>
      <pubDate>Fri, 02 Mar 2007 10:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954601#M290827</guid>
      <dc:creator>Karsten Löperick</dc:creator>
      <dc:date>2007-03-02T10:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954602#M290828</link>
      <description># vi program&lt;BR /&gt;du -x . | awk -v INP=$1 '{ if ($1 &amp;gt; 10) {print}}'&lt;BR /&gt;#</description>
      <pubDate>Fri, 02 Mar 2007 10:01:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954602#M290828</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2007-03-02T10:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954603#M290829</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You can pass a shell variable to the 'awk' program like this:&lt;BR /&gt;&lt;BR /&gt;# SZ=1000&lt;BR /&gt;# du -x .|awk -v SZ=${SZ} '{ if($1 &amp;gt; SZ) {print}}'&lt;BR /&gt;&lt;BR /&gt;Notice that 'awk' references the variable named "SZ" without the dollar sign whereas the *value* of the variable in the shell is obtained by specifying the dollar sign.&lt;BR /&gt;&lt;BR /&gt;The '-v SZ=${SZ}' tells 'awk' to estabish as variable called "SZ" using as its value the value obtained from the shell.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 02 Mar 2007 10:08:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954603#M290829</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-02T10:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954604#M290830</link>
      <description>thank you all.&lt;BR /&gt;&lt;BR /&gt;I used Mr. Karsten's code and it worked with the ...'$variable'... quotes. Is there any specific manual that I can read about using variables with the right quotes?</description>
      <pubDate>Fri, 02 Mar 2007 10:12:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954604#M290830</guid>
      <dc:creator>Osman Yagmurdereli</dc:creator>
      <dc:date>2007-03-02T10:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954605#M290831</link>
      <description>Did you bother to examine the example I posted yesterday for you? It told you exactly how to do what you wanted. You are being confused by the awk positional variables vs. shell arguments. Note that anything inside single quotes is not altered in any manner by the shell.&lt;BR /&gt;&lt;BR /&gt;du -x .|awk '{ if($1 &amp;gt; $2) {print}}'&lt;BR /&gt;&lt;BR /&gt;$1 and $2 here refer to awk variables because they are within single quotes.&lt;BR /&gt;&lt;BR /&gt;Now assume that your script does this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;du -x .|awk -v "size=${1}" '{ if($1 &amp;gt; sz) {print}}'&lt;BR /&gt;&lt;BR /&gt;${1} is a shell variable and because it is within double quotes, instantiation will occur so that if you passwd 200 into your script, -v "size=${1}" becomes -v "size=200"; the -v argument to awk says declare size as an awk variable and assign it the value 200. You can then test awk variables againt another awk variable, size.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Mar 2007 10:19:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954605#M290831</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-02T10:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954606#M290832</link>
      <description>Of course I examined it but it looked a little complicated for me so I tried to find a more simplified version. Thanks again for the explanations...</description>
      <pubDate>Fri, 02 Mar 2007 11:09:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954606#M290832</guid>
      <dc:creator>Osman Yagmurdereli</dc:creator>
      <dc:date>2007-03-02T11:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954607#M290833</link>
      <description>As I said yesterday, a better approach to what you are trying to do is to use Perl's File::Find module which is like the find command on steriods. You can call a function as you enter a new directory, a function is called on each file within the directory, and finally you can call a when all the files in a directory have been read. This suggest a mechanism to do your totals quite nicely. I already had a Perl script that was close and I spent about 5 minutes throwing a working, rather robust example together.&lt;BR /&gt;&lt;BR /&gt;For example,&lt;BR /&gt;&lt;BR /&gt;du.pl -s 20000 /etc /usr&lt;BR /&gt;&lt;BR /&gt;will scan /etc and /usr and display the directory names whose contents exceed 20000 bytes.&lt;BR /&gt;&lt;BR /&gt;du.pl -s 20000 -v -i /etc /usr&lt;BR /&gt;will do the same except each directory will also print the total size (-v) and will indent the output (-i) to show the depth of the directory.&lt;BR /&gt;&lt;BR /&gt;du.pl -u will display full usage.&lt;BR /&gt;&lt;BR /&gt;Since you are starting out. I would suggest that you learn only a little shell and then concentrate on learning Perl because Perl will allow you to do everything that shell, awk, sed, grep, ... will do and quite a bit more. As a bonus, most Perl scripts (including this one) will work without modification on Windows if one of the Windows Perl implementations is installed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Mar 2007 15:56:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954607#M290833</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-02T15:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954608#M290834</link>
      <description>I should mention that you should do a man File::Find to understand how the find function in Perl works.</description>
      <pubDate>Fri, 02 Mar 2007 15:57:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954608#M290834</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-02T15:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954609#M290835</link>
      <description>Osman,&lt;BR /&gt;Hope you are looking for something like this :(This is a nice one. shows filesystems values , if it cross the threshold limit) &lt;BR /&gt;&lt;BR /&gt;bdf | awk 'a[split($5,a,"%")-1]&amp;gt;90'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Raj.</description>
      <pubDate>Fri, 02 Mar 2007 18:16:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954609#M290835</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2007-03-02T18:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: sending parameter to awk command (urgent!!!)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954610#M290836</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I used Mr. Karsten's code and it worked with the ...'$variable'... quotes.&lt;BR /&gt;&lt;BR /&gt;Actually that's not what it is doing.&lt;BR /&gt;It is doing: 'abc ...' $variable 'def'&lt;BR /&gt;but without the spaces around $variable.  You could rewrite it as:&lt;BR /&gt;  'abc ...'"$variable"'def'&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is there any specific manual that I can read about using variables with the right quotes?&lt;BR /&gt;&lt;BR /&gt;You can use man sh-posix or ksh.  Basically $variables are not expanded in single quotes.&lt;BR /&gt;&lt;BR /&gt;I would recommend you use JRF's approach with -v.  (The trouble with Karsten's code is I never thought about doing that before.  ;-)&lt;BR /&gt;&lt;BR /&gt;If I didn't use -v would have done:&lt;BR /&gt;awk "{ if(\$1 &amp;gt; $variable) {print}}"&lt;BR /&gt;&lt;BR /&gt;This requires you rigorously quote the "$" for awk variables.  This can be painful for long awk scripts I write like:&lt;BR /&gt;$ ... awk .... '&lt;BR /&gt;BEGIN { ... }&lt;BR /&gt;{&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;END { ... }' files ...</description>
      <pubDate>Fri, 02 Mar 2007 22:10:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sending-parameter-to-awk-command-urgent/m-p/3954610#M290836</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-02T22:10:40Z</dc:date>
    </item>
  </channel>
</rss>

