<?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: building dynamically a find command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936779#M495302</link>
    <description>&lt;P&gt;Hi Steven,&lt;/P&gt;&lt;P&gt;Thanks to try to help here.&lt;/P&gt;&lt;P&gt;I need to build dynamically my find command and then execute it.&lt;/P&gt;&lt;P&gt;The bigest problem I have (and why I need to build it dynamically before to execute), is that I don't know users. This is why I need to parse users, build the string with -user n1 -o -user n2 ..... -o -user n.&lt;/P&gt;&lt;P&gt;You see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 16:31:41 GMT</pubDate>
    <dc:creator>SwissKnife</dc:creator>
    <dc:date>2017-02-02T16:31:41Z</dc:date>
    <item>
      <title>building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936724#M495300</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To simplify I will to come with a short example.&lt;/P&gt;&lt;P&gt;Suppose&lt;/P&gt;&lt;P&gt;I want to run something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG_DIR="/su01/"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG_NAME=*.log&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AA="-user toto -o -user tata"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myFIND="find $LOGDIR -type f -name ${LOG_NAME}&amp;nbsp; \( $AA \) -print"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't want a substitution for the * joker and echo ${myFIND} should show this&lt;/P&gt;&lt;P&gt;find /su01 -type f -name&lt;STRONG&gt; *.log&lt;/STRONG&gt;&amp;nbsp; \( -user toto -o -user tata \) -print&lt;/P&gt;&lt;P&gt;and not&lt;/P&gt;&lt;P&gt;find /su01 -type f -name &lt;STRONG&gt;afile_001.log&lt;/STRONG&gt; \( -user toto -o -user tata \) -print&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that I will be able to execute the myFIND command&lt;/P&gt;&lt;P&gt;myfind&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas ?&lt;/P&gt;&lt;P&gt;Kind regards, Den.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936724#M495300</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2017-02-02T15:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936766#M495301</link>
      <description>&lt;P&gt;&amp;gt; LOG_NAME=*.log&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Normally (without quotation or escapes or disabling "globbing"), the&lt;BR /&gt;shell will expand that "*.tmp", which you apparently don't want.&amp;nbsp; One&lt;BR /&gt;way to avoid that is quotation:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG_NAME='*.log'&lt;BR /&gt;or:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG_NAME="*.log"&lt;BR /&gt;&lt;BR /&gt;&amp;gt; After that I will be able to execute the myFIND command&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; myfind&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Eh?&amp;nbsp; "myFIND" is a shell variable, not a command (or alias).&amp;nbsp; You&lt;BR /&gt;can't "execute" it that way.&amp;nbsp; (And "myfind" is not "myFIND".)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] echo ${myFIND} should show this [...]&lt;BR /&gt;&lt;BR /&gt;mba$ touch fred.log&lt;BR /&gt;mba$ LOG_DIR="/su01/"&lt;BR /&gt;mba$ LOG_NAME='*.log'&lt;BR /&gt;mba$ AA="-user toto -o -user tata"&lt;BR /&gt;mba$ myFIND="find $LOG_DIR -type f -name ${LOG_NAME}&amp;nbsp; \( $AA \) -print"&lt;BR /&gt;&lt;BR /&gt;mba$ echo "$myFIND"&lt;BR /&gt;find /su01/ -type f -name *.log&amp;nbsp; \( -user toto -o -user tata \) -print&lt;BR /&gt;&lt;BR /&gt;but:&lt;BR /&gt;&lt;BR /&gt;mba$ echo $myFIND&lt;BR /&gt;find /su01/ -type f -name fred.log \( -user toto -o -user tata \) -print&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; It can help to try to think about these expressions the way the shell&lt;BR /&gt;thinks about them (which can be complicated).&lt;BR /&gt;&lt;BR /&gt;&amp;gt; To simplify [...]&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Too simple.&amp;nbsp; What, exactly, would you like to do?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:54:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936766#M495301</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2017-02-02T15:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936779#M495302</link>
      <description>&lt;P&gt;Hi Steven,&lt;/P&gt;&lt;P&gt;Thanks to try to help here.&lt;/P&gt;&lt;P&gt;I need to build dynamically my find command and then execute it.&lt;/P&gt;&lt;P&gt;The bigest problem I have (and why I need to build it dynamically before to execute), is that I don't know users. This is why I need to parse users, build the string with -user n1 -o -user n2 ..... -o -user n.&lt;/P&gt;&lt;P&gt;You see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:31:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936779#M495302</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2017-02-02T16:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936794#M495303</link>
      <description>&lt;P&gt;&amp;gt; You see.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Not entirely.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I'll guess that you could use a shell script.&amp;nbsp; This shell script&lt;BR /&gt;could be executed with a command like "myscript" (if it's on your PATH).&lt;BR /&gt;Somewhere in this shell script, you'd have a "find" command, and some of&lt;BR /&gt;the items on the "find" command line would be variables.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Among the things I still don't know:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; LOG_DIR="/su01/"&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; How do you want to specify this directory?&amp;nbsp; Or is it always the same?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; LOG_NAME=*.log&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; How do you want to specify this (wildcard) file spec?&amp;nbsp; Or is it&lt;BR /&gt;always the same?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; AA="-user toto -o -user tata"&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; How do you want to specify the list of users?&amp;nbsp; (You could specify the&lt;BR /&gt;actual "find" options, or the script could take a space-separated list&lt;BR /&gt;of users, and add the "-user" and "-o" tokens, for example.&amp;nbsp; As usual,&lt;BR /&gt;many things are possible.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...]&amp;nbsp; What, exactly, would you like to do?&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; "Exactly" includes all the details.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; If your worst problem is stopping the shell from expanding "*.log",&lt;BR /&gt;then adding some quotation marks may solve it.&amp;nbsp; If you want to write a&lt;BR /&gt;fancy shell script, then you need first to decide what you'd like it to&lt;BR /&gt;do.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I can imagine a script which you might run like this:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ./myfind /su01 '*.log' toto tata&lt;BR /&gt;&lt;BR /&gt;I don't want to write it, but it should be possible.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 17:04:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936794#M495303</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2017-02-02T17:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936916#M495304</link>
      <description>&lt;P&gt;&amp;nbsp;&amp;nbsp; Some potentially useful techniques:&lt;BR /&gt;&lt;BR /&gt;pro3$ cat f1.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;echo "arg1: &amp;gt;$1&amp;lt;"&lt;BR /&gt;echo "arg2: &amp;gt;$2&amp;lt;"&lt;BR /&gt;&lt;BR /&gt;shift 2&lt;BR /&gt;&lt;BR /&gt;args="$@"&lt;BR /&gt;&lt;BR /&gt;echo "args: &amp;gt;${args}&amp;lt;"&lt;BR /&gt;&lt;BR /&gt;fa=` echo ${args} | sed -e 's/&amp;nbsp; */ -o -user /g' `&lt;BR /&gt;fa=` echo ${fa} | sed -e 's/\([^ ].*\)/-user \1/' `&lt;BR /&gt;&lt;BR /&gt;echo "fa: &amp;gt;${fa}&amp;lt;"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;pro3$ ./f1.sh dir '*.log' u1 u2 u3&lt;BR /&gt;arg1: &amp;gt;dir&amp;lt;&lt;BR /&gt;arg2: &amp;gt;*.log&amp;lt;&lt;BR /&gt;args: &amp;gt;u1 u2 u3&amp;lt;&lt;BR /&gt;fa: &amp;gt;-user u1 -o -user u2 -o -user u3&amp;lt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 00:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6936916#M495304</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2017-02-03T00:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: building dynamically a find command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6937276#M495305</link>
      <description>&lt;P&gt;&amp;gt;Normally (without quotation or escapes or disabling "globbing"), the shell will expand that "*.tmp"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a complicated case recently where I just gave up and used the noglob hammer.&lt;/P&gt;&lt;P&gt;I had multiple levels of quoting and expansion.&lt;/P&gt;&lt;P&gt;for command in \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; "showspace -cpg *" \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set -f # noglob&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; cli $command&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I couldn't quote the $command since I want it to expand into multiple tokens.&lt;/P&gt;&lt;P&gt;I tried using '*" but the app didn't like it.&amp;nbsp; I used \"*\" and it worked, only because the app ignored the quotes.&lt;/P&gt;&lt;P&gt;So it seem that noglob was the right solution in my case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; build the string with -user n1 -o -user n2 ..... -o -user n.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Build that dynamically but the rest statically and Steven showed?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 01:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/building-dynamically-a-find-command/m-p/6937276#M495305</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2017-02-05T01:27:40Z</dc:date>
    </item>
  </channel>
</rss>

