<?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: Korn shell programming in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480432#M776752</link>
    <description>Jasmin:&lt;BR /&gt;&lt;BR /&gt;With regard to your last question about reading and comparing to the previously read line; 'awk' scripts can do this.&lt;BR /&gt;&lt;BR /&gt;Consider this example:&lt;BR /&gt;&lt;BR /&gt;echo "1\n2\n3\n3\n3\n4\n4" |     awk 'BEGIN {getline;X=$0;print $0};&lt;BR /&gt;    {if ($0 !~ X) {print $0;X=$0}}'&lt;BR /&gt;&lt;BR /&gt;Instead of printing seven lines 1,2,3,3,3,4,4&lt;BR /&gt;this would merely print four, unique lines: 1,2,3,4.&lt;BR /&gt;&lt;BR /&gt;As noted in the preceeding posts, the '-u' option of sort or the 'uniq' filter are general methods for accomplishing this.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 08 Jan 2001 19:15:42 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2001-01-08T19:15:42Z</dc:date>
    <item>
      <title>Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480419#M776739</link>
      <description>I got a question regarding Korn shell programming and i'm wondering in which section i might post it?</description>
      <pubDate>Mon, 08 Jan 2001 16:16:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480419#M776739</guid>
      <dc:creator>Jasmin Berube</dc:creator>
      <dc:date>2001-01-08T16:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480420#M776740</link>
      <description>Jasmin:&lt;BR /&gt;&lt;BR /&gt;Here is fine.  What is your question?&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jan 2001 16:23:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480420#M776740</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-01-08T16:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480421#M776741</link>
      <description>Go ahead and post it here.  We'll help you as best we can.</description>
      <pubDate>Mon, 08 Jan 2001 16:27:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480421#M776741</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2001-01-08T16:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480422#M776742</link>
      <description>ok here is my question?&lt;BR /&gt;i got a file sorted by user name (at the beginning of the line) and i want to split it out or generation other files for each user, fo exemple if my file have 3 lines beginning with Jasmin, 12 lines beginning with Bob and 7 lines with Fred, how i can take those lines out of this file to create new files for each users? I got about 200 users so i want to make a script to do it!</description>
      <pubDate>Mon, 08 Jan 2001 16:39:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480422#M776742</guid>
      <dc:creator>Jasmin Berube</dc:creator>
      <dc:date>2001-01-08T16:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480423#M776743</link>
      <description>Jasmin:&lt;BR /&gt;&lt;BR /&gt;'grep' is one way:&lt;BR /&gt;&lt;BR /&gt;# grep -i Jasmin /tmp/input &amp;gt; /tmp/output&lt;BR /&gt;&lt;BR /&gt;The above looks case-insensitively for "Jasmin" in /tmp/input, and writes matching entries to /tmp/output.&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jan 2001 16:45:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480423#M776743</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-01-08T16:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480424#M776744</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Since the matching characters of Jasmin, Bob etc start at the beginning of the lines, if you are looking for precision and omit "Bob" occurring in the middle of the line, you may want to try:&lt;BR /&gt;&lt;BR /&gt;grep "^Bob" LOG &amp;gt; Bob.log&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;</description>
      <pubDate>Mon, 08 Jan 2001 16:53:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480424#M776744</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-01-08T16:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480425#M776745</link>
      <description>cat yourfile | awk '{&lt;BR /&gt;name = $1;&lt;BR /&gt;print $0 &amp;gt; name;&lt;BR /&gt;}'</description>
      <pubDate>Mon, 08 Jan 2001 17:05:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480425#M776745</guid>
      <dc:creator>Curtis Larson</dc:creator>
      <dc:date>2001-01-08T17:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480426#M776746</link>
      <description>Here is a script that should do what you want to do:&lt;BR /&gt;&lt;BR /&gt;cat users_file | sort -u &amp;gt;&amp;gt; users_file1&lt;BR /&gt;for i in `cat users_file1`&lt;BR /&gt;do&lt;BR /&gt;grep $i users_file &amp;gt;&amp;gt; $i.file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The first line of the script will do a cat of your data file, sort it, and only give you one entry for each user in user_file1.  Then in the next line it takes each users_file1 entry and greps for it in users_file and writes the output to user_name.file.  It will do this for every entry in users_file1.  Change the file names in the script to reflect whatever the file names you want to use are.&lt;BR /&gt;&lt;BR /&gt;I hope this helps you.</description>
      <pubDate>Mon, 08 Jan 2001 17:07:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480426#M776746</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2001-01-08T17:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480427#M776747</link>
      <description>Jasmin,&lt;BR /&gt;Curtis' answer looks good, except you may want to replace the &amp;gt; with &amp;gt;&amp;gt;, so that you get all the lines. &amp;gt; means overwrite, and &amp;gt;&amp;gt; means append.&lt;BR /&gt;Mo</description>
      <pubDate>Mon, 08 Jan 2001 17:09:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480427#M776747</guid>
      <dc:creator>Maureen Gunkel</dc:creator>
      <dc:date>2001-01-08T17:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480428#M776748</link>
      <description>Is there a unix command that reads each line and when current line is the same as the previous keeps this line until it hits a line different?&lt;BR /&gt;I've already heard that there a command to do that... i might be wrong.</description>
      <pubDate>Mon, 08 Jan 2001 18:15:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480428#M776748</guid>
      <dc:creator>Jasmin Berube</dc:creator>
      <dc:date>2001-01-08T18:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480429#M776749</link>
      <description>If you are sorting something then you can use 'sort -u' and that will sort the output, but only give one of each item if there are multiples.</description>
      <pubDate>Mon, 08 Jan 2001 18:21:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480429#M776749</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2001-01-08T18:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480430#M776750</link>
      <description>Here's one more:&lt;BR /&gt;&lt;BR /&gt;for i in `sort -u the_file | awk '{print $1}'`; do&lt;BR /&gt;  grep "^$i" the_file &amp;gt;&amp;gt; $i.out&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Ovidiu</description>
      <pubDate>Mon, 08 Jan 2001 18:23:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480430#M776750</guid>
      <dc:creator>Ovidiu D. Raita</dc:creator>
      <dc:date>2001-01-08T18:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480431#M776751</link>
      <description>you look at the sort command the -u option and the uniq command and see if they are what your looking for</description>
      <pubDate>Mon, 08 Jan 2001 18:25:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480431#M776751</guid>
      <dc:creator>Curtis Larson</dc:creator>
      <dc:date>2001-01-08T18:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480432#M776752</link>
      <description>Jasmin:&lt;BR /&gt;&lt;BR /&gt;With regard to your last question about reading and comparing to the previously read line; 'awk' scripts can do this.&lt;BR /&gt;&lt;BR /&gt;Consider this example:&lt;BR /&gt;&lt;BR /&gt;echo "1\n2\n3\n3\n3\n4\n4" |     awk 'BEGIN {getline;X=$0;print $0};&lt;BR /&gt;    {if ($0 !~ X) {print $0;X=$0}}'&lt;BR /&gt;&lt;BR /&gt;Instead of printing seven lines 1,2,3,3,3,4,4&lt;BR /&gt;this would merely print four, unique lines: 1,2,3,4.&lt;BR /&gt;&lt;BR /&gt;As noted in the preceeding posts, the '-u' option of sort or the 'uniq' filter are general methods for accomplishing this.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Jan 2001 19:15:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480432#M776752</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-01-08T19:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480433#M776753</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To reduce the number of iterations within the for loop for performance reasons, add an additional "| uniq" behind "awk '{print $1}'" in Ovidiu's script.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Jan 2001 00:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-programming/m-p/2480433#M776753</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-01-09T00:00:33Z</dc:date>
    </item>
  </channel>
</rss>

