<?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 script function extract line number in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015750#M912201</link>
    <description>If you remove the word "function" from your scripts it should work OK.  It did for me.</description>
    <pubDate>Fri, 04 Jul 2003 13:19:41 GMT</pubDate>
    <dc:creator>Ian Lochray</dc:creator>
    <dc:date>2003-07-04T13:19:41Z</dc:date>
    <item>
      <title>ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015733#M912184</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;As a starter, I would need some help on ksh scripting.&lt;BR /&gt;&lt;BR /&gt;I'd like to retrieve the line number of a string in a file by using a function :&lt;BR /&gt;&lt;BR /&gt;function getLineNr {&lt;BR /&gt;# parameters : $1 linenr variable&lt;BR /&gt;#              $2 search string&lt;BR /&gt;export $2&lt;BR /&gt;$1=`cat -n /tmp/myfile.tmp | grep "$2" | awk '{print $1}'`&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;In the script I call the function as follows :&lt;BR /&gt; ln=" "&lt;BR /&gt; getLineNr ln "Statistics ( 2K)"&lt;BR /&gt;&lt;BR /&gt;Running the script gives the error :&lt;BR /&gt; getLineNr[x]: (: is not an identifier&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for any help.&lt;BR /&gt;Franky&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 11:25:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015733#M912184</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T11:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015734#M912185</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It could be your variable "In" is getting mistaken for part of the "for x in y" structure, try calling it something unique.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;Darren.</description>
      <pubDate>Fri, 04 Jul 2003 11:39:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015734#M912185</guid>
      <dc:creator>Darren Prior</dc:creator>
      <dc:date>2003-07-04T11:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015735#M912186</link>
      <description>try the following line&lt;BR /&gt;&lt;BR /&gt;awk ' /searchstring/ { print NR}' filename&lt;BR /&gt;&lt;BR /&gt;It will print the linenumber which contains the searchstring in filename&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 11:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015735#M912186</guid>
      <dc:creator>Dagmar Boelen</dc:creator>
      <dc:date>2003-07-04T11:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015736#M912187</link>
      <description>Darren,&lt;BR /&gt;&lt;BR /&gt;Thanks for the answer but that did no solve the problem.&lt;BR /&gt;&lt;BR /&gt;Franky</description>
      <pubDate>Fri, 04 Jul 2003 12:01:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015736#M912187</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015737#M912188</link>
      <description>Hi Franky,&lt;BR /&gt;Don't pass the variable to the funcion, and define correctly the function.&lt;BR /&gt;You musn't do cat -n the NR variable of awk stores the record number.&lt;BR /&gt;&lt;BR /&gt;My proposal:&lt;BR /&gt;&lt;BR /&gt;#------------------------&lt;BR /&gt;#script&lt;BR /&gt;&lt;BR /&gt;function getLineNr() {&lt;BR /&gt;# $1 search string&lt;BR /&gt;&lt;BR /&gt;awk '/'$1'/ {print NR}' /tmp/myfile.tmp&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;In=`getLineNr "Statistics (2K)"`&lt;BR /&gt;&lt;BR /&gt;#end script&lt;BR /&gt;#----------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Be carefuly wit the quotation. The scripts works for me.&lt;BR /&gt;&lt;BR /&gt;Frank.</description>
      <pubDate>Fri, 04 Jul 2003 12:07:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015737#M912188</guid>
      <dc:creator>Francisco J. Soler</dc:creator>
      <dc:date>2003-07-04T12:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015738#M912189</link>
      <description>Dagmar,&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;Change the function statement into your proposal :&lt;BR /&gt;function getLineNr {&lt;BR /&gt;# parameters : $1 linenr variable&lt;BR /&gt;#              $2 search string&lt;BR /&gt;export $2&lt;BR /&gt;$1=`awk '/$2/{ print NR }' /tmp/myfile.tmp`&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, this results in exactly the same error message.&lt;BR /&gt;&lt;BR /&gt;Franky</description>
      <pubDate>Fri, 04 Jul 2003 12:09:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015738#M912189</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015739#M912190</link>
      <description>Hi Franky&lt;BR /&gt;&lt;BR /&gt;I forget it, at the end of script echo the In varible to see your content.&lt;BR /&gt;&lt;BR /&gt;echo $In&lt;BR /&gt;&lt;BR /&gt;Bye&lt;BR /&gt;Frank.</description>
      <pubDate>Fri, 04 Jul 2003 12:09:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015739#M912190</guid>
      <dc:creator>Francisco J. Soler</dc:creator>
      <dc:date>2003-07-04T12:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015740#M912191</link>
      <description>Hi Franky&lt;BR /&gt;&lt;BR /&gt;I forget it, at the end of script echo the In varible to see its contents&lt;BR /&gt;&lt;BR /&gt;echo $In&lt;BR /&gt;&lt;BR /&gt;Bye&lt;BR /&gt;Frank.</description>
      <pubDate>Fri, 04 Jul 2003 12:09:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015740#M912191</guid>
      <dc:creator>Francisco J. Soler</dc:creator>
      <dc:date>2003-07-04T12:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015741#M912192</link>
      <description>Hi,&lt;BR /&gt;i think your problem is in the name of the file,&lt;BR /&gt;because the () are interpreted by the shell expander.&lt;BR /&gt;&lt;BR /&gt;Try&lt;BR /&gt;getLineNr ln "Statistics \( 2K\)"&lt;BR /&gt;&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:21:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015741#M912192</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-04T12:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015742#M912193</link>
      <description>Francesco,&lt;BR /&gt;&lt;BR /&gt;Thanks for your answer but I get&lt;BR /&gt;syntax error at line 11 : `(' unexpected&lt;BR /&gt;&lt;BR /&gt;function getLineNr(){&lt;BR /&gt;# $1 search string&lt;BR /&gt;# ln line number&lt;BR /&gt;awk '/'$1'/{print NR}' /tmp/myfile.tmp&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Omitting the '()' results in :&lt;BR /&gt;syntax error at line 14 : `awk' unexpected&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Franky&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:25:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015742#M912193</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015743#M912194</link>
      <description>why function? When you can do it as follows.&lt;BR /&gt;&lt;BR /&gt;nl your_file|grep -i "your string"&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;cat file|nl|grep "your string"</description>
      <pubDate>Fri, 04 Jul 2003 12:28:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015743#M912194</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-07-04T12:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015744#M912195</link>
      <description>Massimo, &lt;BR /&gt;&lt;BR /&gt;Thanks also for your answer but I event with that in mind I get : syntax error at line 11 : `(' unexpected &lt;BR /&gt;&lt;BR /&gt;In order to make this issue more simple, I changed the search string to "Statistics".&lt;BR /&gt;&lt;BR /&gt;I still get the same error.&lt;BR /&gt;&lt;BR /&gt;Franky&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:32:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015744#M912195</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015745#M912196</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;can you please post:&lt;BR /&gt;- actual script&lt;BR /&gt;- example of the content of the file &lt;BR /&gt;&lt;BR /&gt;Just to clarify...&lt;BR /&gt;   Massimo&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:33:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015745#M912196</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-04T12:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015746#M912197</link>
      <description>Hello Anil,&lt;BR /&gt;&lt;BR /&gt;Thanks for your contribution too.&lt;BR /&gt;&lt;BR /&gt;I need the function because I must repeat this procedure a number of times for different strings.&lt;BR /&gt;&lt;BR /&gt;Using a function will make it possible to do future changes in only one place.&lt;BR /&gt;&lt;BR /&gt;Franky</description>
      <pubDate>Fri, 04 Jul 2003 12:35:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015746#M912197</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015747#M912198</link>
      <description>Hi,&lt;BR /&gt;maybe i eat too juch, but checking with a cluster script, you don't have to use the ()&lt;BR /&gt;in the definition.&lt;BR /&gt;&lt;BR /&gt;function customer_defined_run_cmds&lt;BR /&gt;{&lt;BR /&gt;# ADD customer defined run commands.&lt;BR /&gt;: # do nothing instruction, because a function must contain some command.&lt;BR /&gt; &lt;BR /&gt; # Attivazione dell'architettura di Control-M&lt;BR /&gt; #su - ecsuser -c start_all&lt;BR /&gt; #su - ctmuser -c start-ctm&lt;BR /&gt; #test_return 51&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:37:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015747#M912198</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-04T12:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015748#M912199</link>
      <description>Massimo,&lt;BR /&gt;&lt;BR /&gt;This is the current script :&lt;BR /&gt;&lt;BR /&gt;#! /bin/ksh&lt;BR /&gt;function getLineNr(){&lt;BR /&gt;# $1 search string&lt;BR /&gt;awk '/'$1'/{print NR}' /tmp/monitor_dmfcache.tmp&lt;BR /&gt;}&lt;BR /&gt;ln=`getLineNr "Statistics"`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is the file :&lt;BR /&gt;&lt;BR /&gt;! Buffer Status: WBWAIT,SHARED&lt;BR /&gt;!  Buffer Manager Id: 35  Connected servers 2&lt;BR /&gt;!  CP count:     8  CP index :     0  CP check :     0&lt;BR /&gt;!  Database cache size:    40  Table cache size:    40&lt;BR /&gt;!  Statistics------------------------------------------------------------------&lt;BR /&gt;!         MUTEXWAIT  RECLAIM&lt;BR /&gt;!               0         0&lt;BR /&gt;!     CONSISTENCY POINT FLUSHES        WRITE BEHIND FLUSHES&lt;BR /&gt;!               7                             0&lt;BR /&gt;!  Buffer Cache Configuration ( 2K) -------------------------------------------&lt;BR /&gt;!  Buffer count:    8432  Bucket count: 16383 Group count:      54 Size:      8&lt;BR /&gt;!  Free count:     7740 Limit:     250 Modify count:     260 Limit:    6000&lt;BR /&gt;!  Free group count:       47 Modify group count:       7&lt;BR /&gt;!  Fixed count:       0 Group fixed count:       0&lt;BR /&gt;!  Write Behind start limit:    4800, Write Behind end limit:    4000&lt;BR /&gt;!  Statistics ( 2K) -----------------------------------------------------------&lt;BR /&gt;!        FIX CALLS       HITS      CHECK    REFRESH       READ       TOSS&lt;BR /&gt;!           835574     807656       9470          0       5487       2664&lt;BR /&gt;!      UNFIX CALLS      DIRTY      FORCE      WRITE     IOWAIT       SYNC&lt;BR /&gt;!           182342      14145     107113       1221          3          0&lt;BR /&gt;!           GREADS    GWRITES      GWAIT      GSYNC   FREEWAIT     FCWAIT&lt;BR /&gt;!            19648          0          0          0          0          0&lt;BR /&gt;!  Buffer Cache Configuration ( 4K) -------------------------------------------&lt;BR /&gt;!  Buffer count:    8432  Bucket count: 16383 Group count:      54 Size:      8&lt;BR /&gt;!  Free count:     8000 Limit:     250 Modify count:       0 Limit:    6000&lt;BR /&gt;!  Free group count:       54 Modify group count:       0&lt;BR /&gt;!  Fixed count:       0 Group fixed count:       0&lt;BR /&gt;!  Write Behind start limit:    4800, Write Behind end limit:    4000&lt;BR /&gt;!  Statistics ( 4K) -----------------------------------------------------------&lt;BR /&gt;!        FIX CALLS       HITS      CHECK    REFRESH       READ       TOSS&lt;BR /&gt;!             2374       2318          0          0         30          0&lt;BR /&gt;!      UNFIX CALLS      DIRTY      FORCE      WRITE     IOWAIT       SYNC&lt;BR /&gt;!              214          0         84          0          0          0&lt;BR /&gt;!           GREADS    GWRITES      GWAIT      GSYNC   FREEWAIT     FCWAIT&lt;BR /&gt;!               26          0          0          0          0          0&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:41:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015748#M912199</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T12:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015749#M912200</link>
      <description>Hi Frank,&lt;BR /&gt;&lt;BR /&gt;This script worked for me.&lt;BR /&gt;&lt;BR /&gt;#/bin/ksh&lt;BR /&gt;function myFunc {&lt;BR /&gt;        awk ' /'$1'/{ print NR}' myfile&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;ln=`myFunc "aa" `&lt;BR /&gt;echo $ln&lt;BR /&gt;~</description>
      <pubDate>Fri, 04 Jul 2003 13:14:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015749#M912200</guid>
      <dc:creator>Dagmar Boelen</dc:creator>
      <dc:date>2003-07-04T13:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015750#M912201</link>
      <description>If you remove the word "function" from your scripts it should work OK.  It did for me.</description>
      <pubDate>Fri, 04 Jul 2003 13:19:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015750#M912201</guid>
      <dc:creator>Ian Lochray</dc:creator>
      <dc:date>2003-07-04T13:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015751#M912202</link>
      <description>I agree. You can remove the word function or you can remove the (). Both solutions work!!</description>
      <pubDate>Fri, 04 Jul 2003 13:21:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015751#M912202</guid>
      <dc:creator>Dagmar Boelen</dc:creator>
      <dc:date>2003-07-04T13:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script function extract line number</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015752#M912203</link>
      <description>Hi Dagmar,&lt;BR /&gt;&lt;BR /&gt;Similar result with your last hint :&lt;BR /&gt;syntax error at line 11 : `(' unexpected&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Franky</description>
      <pubDate>Fri, 04 Jul 2003 13:27:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-function-extract-line-number/m-p/3015752#M912203</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2003-07-04T13:27:10Z</dc:date>
    </item>
  </channel>
</rss>

