<?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: KSH syntax in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859037#M95623</link>
    <description>You can always use this kind of script:&lt;BR /&gt;&lt;BR /&gt;# cat &amp;gt; test&lt;BR /&gt;1234&lt;BR /&gt;# cat &amp;gt; test2&lt;BR /&gt;1245&lt;BR /&gt;# cat &amp;gt; test.ksh&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;for i in test*&lt;BR /&gt;do&lt;BR /&gt;if grep -q 1234 $i&lt;BR /&gt;then&lt;BR /&gt;echo "$i contains 1234"&lt;BR /&gt;elif grep -q 1245 $i&lt;BR /&gt;then&lt;BR /&gt;echo "$i  contains 1245"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;# chmod 777 test.ksh&lt;BR /&gt;# ./test.ksh&lt;BR /&gt;test  contains 1234&lt;BR /&gt;test.ksh  contains 1234&lt;BR /&gt;test2  contains 1245&lt;BR /&gt;&lt;BR /&gt;Francois-Xavier</description>
    <pubDate>Fri, 06 Dec 2002 11:30:16 GMT</pubDate>
    <dc:creator>F. X. de Montgolfier</dc:creator>
    <dc:date>2002-12-06T11:30:16Z</dc:date>
    <item>
      <title>KSH syntax</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859033#M95619</link>
      <description>I have four kinds of text files. I need to do a different action for each  file type. I can identify the file by a unique string it contains. Can you help me with the Korn Shell script syntax? I was trying to use case and grep and was not successful.&lt;BR /&gt;&lt;BR /&gt;Tanks in dvance.&lt;BR /&gt;Andrej</description>
      <pubDate>Fri, 06 Dec 2002 10:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859033#M95619</guid>
      <dc:creator>Andrej Vavro</dc:creator>
      <dc:date>2002-12-06T10:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: KSH syntax</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859034#M95620</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you don't like 'else if' constructs (I don't) then using a function makes it easier to code, something like...&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;function process_file {&lt;BR /&gt;if grep -q &lt;UNIQUE string="" 1=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 1=""&gt;&lt;BR /&gt; return&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if grep -q &lt;UNIQUE string="" 2=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 2=""&gt;&lt;BR /&gt; return&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if grep -q &lt;UNIQUE string="" 3=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 3=""&gt;&lt;BR /&gt; return&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if grep -q &lt;UNIQUE string="" 3=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 3=""&gt;&lt;BR /&gt; return&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;print "No action for file ${1}" &amp;gt;&amp;amp;2&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;process_file &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Otherwise you could have...&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;# assume file_name is in ${1}&lt;BR /&gt;&lt;BR /&gt;if grep -q &lt;UNIQUE string="" 1=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 1=""&gt;&lt;BR /&gt;elif grep -q &lt;UNIQUE string="" 2=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 2=""&gt;&lt;BR /&gt;elif grep -q &lt;UNIQUE string="" 3=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 3=""&gt;&lt;BR /&gt;elif grep -q &lt;UNIQUE string="" 3=""&gt; ${1}&lt;BR /&gt;then &lt;ACTION 4=""&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/FILENAME&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;&lt;/ACTION&gt;&lt;/UNIQUE&gt;</description>
      <pubDate>Fri, 06 Dec 2002 10:33:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859034#M95620</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-12-06T10:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: KSH syntax</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859035#M95621</link>
      <description>Hi Andrej,&lt;BR /&gt;&lt;BR /&gt;using case, you could do the following:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;file=$1&lt;BR /&gt;S1=string1&lt;BR /&gt;S2=string2&lt;BR /&gt;S3=string3&lt;BR /&gt;S4=string4&lt;BR /&gt;&lt;BR /&gt;for a in 1 2 3 4; do&lt;BR /&gt;grep -q `eval echo '$S'$a` $file &amp;amp;&amp;amp; FLAG=$a&lt;BR /&gt;done&lt;BR /&gt;case $FLAG&lt;BR /&gt;in&lt;BR /&gt; 1)&lt;BR /&gt;  echo file type 1&lt;BR /&gt;  ;;&lt;BR /&gt; 2)&lt;BR /&gt;  echo file type 2&lt;BR /&gt;  ;;&lt;BR /&gt; 3)&lt;BR /&gt;  echo file type 3&lt;BR /&gt;  ;;&lt;BR /&gt; 4)&lt;BR /&gt;  echo file type 4&lt;BR /&gt;  ;;&lt;BR /&gt; *)&lt;BR /&gt;  echo unknown file type&lt;BR /&gt;  ;;&lt;BR /&gt;esac</description>
      <pubDate>Fri, 06 Dec 2002 10:42:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859035#M95621</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-12-06T10:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: KSH syntax</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859036#M95622</link>
      <description>Hi&lt;BR /&gt;what's about this:&lt;BR /&gt;&lt;BR /&gt;grep -il "uniq1" * | xargs &lt;COMMAND1&gt;&lt;BR /&gt;grep -il "uniq2" * | xargs &lt;COMMAND2&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;/COMMAND2&gt;&lt;/COMMAND1&gt;</description>
      <pubDate>Fri, 06 Dec 2002 10:54:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859036#M95622</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-12-06T10:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: KSH syntax</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859037#M95623</link>
      <description>You can always use this kind of script:&lt;BR /&gt;&lt;BR /&gt;# cat &amp;gt; test&lt;BR /&gt;1234&lt;BR /&gt;# cat &amp;gt; test2&lt;BR /&gt;1245&lt;BR /&gt;# cat &amp;gt; test.ksh&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;for i in test*&lt;BR /&gt;do&lt;BR /&gt;if grep -q 1234 $i&lt;BR /&gt;then&lt;BR /&gt;echo "$i contains 1234"&lt;BR /&gt;elif grep -q 1245 $i&lt;BR /&gt;then&lt;BR /&gt;echo "$i  contains 1245"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;# chmod 777 test.ksh&lt;BR /&gt;# ./test.ksh&lt;BR /&gt;test  contains 1234&lt;BR /&gt;test.ksh  contains 1234&lt;BR /&gt;test2  contains 1245&lt;BR /&gt;&lt;BR /&gt;Francois-Xavier</description>
      <pubDate>Fri, 06 Dec 2002 11:30:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-syntax/m-p/2859037#M95623</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-06T11:30:16Z</dc:date>
    </item>
  </channel>
</rss>

