<?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: for loop with command line parameters in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113763#M446530</link>
    <description>Answers were enough to go in the good way !&lt;BR /&gt;Thanks Guys.</description>
    <pubDate>Fri, 13 Jun 2008 12:44:47 GMT</pubDate>
    <dc:creator>Leo The Cat</dc:creator>
    <dc:date>2008-06-13T12:44:47Z</dc:date>
    <item>
      <title>for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113752#M446519</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I'd like to do something like that: call a script named test.ksh with *.txt in command line parameter. &lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;./test.ksh *.txt&lt;BR /&gt;&lt;BR /&gt;Actually my script is &lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;for target in $1 &lt;BR /&gt;do&lt;BR /&gt; echo $target&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And the output result provided is &lt;BR /&gt;*.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What is wrong ?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;Regards&lt;BR /&gt;Den.</description>
      <pubDate>Thu, 12 Jun 2008 19:59:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113752#M446519</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-06-12T19:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113753#M446520</link>
      <description>Not sure why you're output would be *.txt. Assuming you want it to list all of the files ending in .txt, either of these options appears to work:&lt;BR /&gt;&lt;BR /&gt;1.) Quote the argument to your existing script: ./test.ksh "*.txt"&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;2.) Change your script to use $* instead of $1</description>
      <pubDate>Thu, 12 Jun 2008 20:05:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113753#M446520</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2008-06-12T20:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113754#M446521</link>
      <description>how about this.&lt;BR /&gt;&lt;BR /&gt;for target in `ls $1`&lt;BR /&gt;do&lt;BR /&gt;echo $target&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2008 20:06:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113754#M446521</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-06-12T20:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113755#M446522</link>
      <description>oops.  typo&lt;BR /&gt;&lt;BR /&gt;for x in `eval ls $*`&lt;BR /&gt;do&lt;BR /&gt;echo $x&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;limited to either 9 or 15 command line args.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2008 20:10:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113755#M446522</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-06-12T20:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113756#M446523</link>
      <description>&lt;!--!*#--&gt;&amp;gt; What is wrong ?&lt;BR /&gt;&lt;BR /&gt;Where to start...&lt;BR /&gt;&lt;BR /&gt;Here's a directory with a few files.&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; ls -l&lt;BR /&gt;total 40&lt;BR /&gt;-rw-rw-rw-   1 antinode   513              4 Jun 12 17:06 a b c .c&lt;BR /&gt;-rw-rw-rw-   1 antinode   513            192 Mar  5 10:54 lame1.c&lt;BR /&gt;-rwxrwxrwx   1 antinode   513             54 Jun 12 17:03 test.ksh&lt;BR /&gt;-rwxrwxrwx   1 antinode   513             56 Jun 12 17:05 test2.ksh&lt;BR /&gt;-rwxrwxrwx   1 antinode   513             54 Jun 12 17:07 test3.ksh&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; echo *.c&lt;BR /&gt;a b c .c lame1.c&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; echo *.fred # No such files exist.&lt;BR /&gt;*.fred&lt;BR /&gt;&lt;BR /&gt;That's what shells do nowadays when wildcard&lt;BR /&gt;expansion ("globbing") comes up empty-handed.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 2.) Change your script to use $* instead of $1&lt;BR /&gt;&lt;BR /&gt;Not such a good idea if you have weird file&lt;BR /&gt;names.  For example:&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; ./test3.ksh *.c&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;.c&lt;BR /&gt;lame1.c&lt;BR /&gt;&lt;BR /&gt;Better:&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; ./test2.ksh *.c&lt;BR /&gt;a b c .c&lt;BR /&gt;lame1.c&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; diff test3.ksh test2.ksh&lt;BR /&gt;3c3&lt;BR /&gt;&amp;lt; for target in $*&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; for target in "$@"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 1.) Quote the argument to your existing&lt;BR /&gt;&amp;gt; script: ./test.ksh "*.txt"&lt;BR /&gt;&lt;BR /&gt;Yeah, but it does put an excessive burden on&lt;BR /&gt;the victim.&lt;BR /&gt;&lt;BR /&gt;And, of course, if your wildcard gets&lt;BR /&gt;expanded into a zillion file names, you can&lt;BR /&gt;overrun the shell's command-line length&lt;BR /&gt;limit, requiring a different approach (of&lt;BR /&gt;which many exist).&lt;BR /&gt;&lt;BR /&gt;"man sh" and friends cover this kind of&lt;BR /&gt;thing, but it's not a three-minute read.</description>
      <pubDate>Thu, 12 Jun 2008 20:22:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113756#M446523</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-06-12T20:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113757#M446524</link>
      <description>&lt;!--!*#--&gt;Oh, yeah.  In case it wasn't obvious:&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; cat test2.ksh&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for target in "$@"&lt;BR /&gt;do&lt;BR /&gt;    echo $target&lt;BR /&gt;done</description>
      <pubDate>Thu, 12 Jun 2008 20:36:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113757#M446524</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-06-12T20:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113758#M446525</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Sorry, to be exact here what I want really to do. &lt;BR /&gt;&lt;BR /&gt;DEST=$2&lt;BR /&gt;cd $1&lt;BR /&gt;for target in `ls $3`&lt;BR /&gt;do&lt;BR /&gt;  if [[ ! -f $2/$target ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Append ..." $DEST/$target&lt;BR /&gt;    #cp $target $DEST&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jun 2008 20:52:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113758#M446525</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-06-12T20:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113759#M446526</link>
      <description>The script is called with 3 arguments&lt;BR /&gt;Source, destination and what king of file ... &lt;BR /&gt;&lt;BR /&gt;Addnewfiles ${ORACLE_HOME}/jdk.orig/jre/lib/ext ${ORACLE_HOME}/jdk/jre/lib/ext *.jar&lt;BR /&gt;&lt;BR /&gt;Sorry for this incomplete and important information.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Den.</description>
      <pubDate>Thu, 12 Jun 2008 20:57:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113759#M446526</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-06-12T20:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113760#M446527</link>
      <description>&amp;gt; [..] to be exact here what I want really to&lt;BR /&gt;&amp;gt; do.&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&lt;BR /&gt;That looks to me like a shell script, which&lt;BR /&gt;is not a description of what you really want&lt;BR /&gt;to do.  Unless it already does what you&lt;BR /&gt;really want to do, in which case, the problem&lt;BR /&gt;is solved, and everyone is happy at last.  If&lt;BR /&gt;you're happy, then I'm happy.  (If you're&lt;BR /&gt;_not_ happy, then you may need to describe&lt;BR /&gt;the problem better.)</description>
      <pubDate>Thu, 12 Jun 2008 20:59:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113760#M446527</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-06-12T20:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113761#M446528</link>
      <description>Sorry Steven&lt;BR /&gt;&lt;BR /&gt;I want to copy files from a directory ($1) into another directory ($2) only for non already exists files and only for particular kind of files ($3). &lt;BR /&gt;&lt;BR /&gt;Thanks for your patience ;-)&lt;BR /&gt;Best Regards&lt;BR /&gt;Den.</description>
      <pubDate>Thu, 12 Jun 2008 21:11:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113761#M446528</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-06-12T21:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113762#M446529</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I want to copy files from a directory ($1) into another directory ($2) only for non already exists files and only for particular kind of files ($3). &lt;BR /&gt;&lt;BR /&gt;Your script works fine, what's the problem?&lt;BR /&gt;DEST=$2&lt;BR /&gt;cd $1&lt;BR /&gt;for target in $(ls $3); do&lt;BR /&gt;   if [[ ! -f $2/$target ]]; then&lt;BR /&gt;      echo "Append ..." $DEST/$target&lt;BR /&gt;      cp $target $DEST&lt;BR /&gt;   fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Note you have a "$2" in the "if".  You should be consistent and use $DEST.&lt;BR /&gt;&lt;BR /&gt;Your only problem is you need to quote your pattern:&lt;BR /&gt;Addnewfiles ${ORACLE_HOME}/jdk.orig/jre/lib/ext \&lt;BR /&gt;${ORACLE_HOME}/jdk/jre/lib/ext "*.jar"</description>
      <pubDate>Fri, 13 Jun 2008 03:11:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113762#M446529</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-06-13T03:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with command line parameters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113763#M446530</link>
      <description>Answers were enough to go in the good way !&lt;BR /&gt;Thanks Guys.</description>
      <pubDate>Fri, 13 Jun 2008 12:44:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop-with-command-line-parameters/m-p/5113763#M446530</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-06-13T12:44:47Z</dc:date>
    </item>
  </channel>
</rss>

