<?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: parsing text by scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584704#M856110</link>
    <description>cat yourFile |&lt;BR /&gt;awk '{&lt;BR /&gt;  split($0,array,"\"");&lt;BR /&gt;  id=array[2];&lt;BR /&gt;  bigA[id]=$0;&lt;BR /&gt;} END {&lt;BR /&gt;  for ( i in bigA )&lt;BR /&gt;    print bigA[i];&lt;BR /&gt;}'</description>
    <pubDate>Tue, 25 Sep 2001 17:48:42 GMT</pubDate>
    <dc:creator>Curtis Larson_1</dc:creator>
    <dc:date>2001-09-25T17:48:42Z</dc:date>
    <item>
      <title>parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584699#M856105</link>
      <description>I want to parse a text file below (either in perl or shell scripting) so that I get&lt;BR /&gt;the last record that has the id no. The&lt;BR /&gt;first field within double quotes is always id no. &lt;BR /&gt;The input text file is below and the output I want to see is in the end. Can't figure it out.?&lt;BR /&gt;Help please.&lt;BR /&gt;&lt;BR /&gt;INPUT FILE:&lt;BR /&gt;==========================&lt;BR /&gt;{"123", "sam", "Test"}&lt;BR /&gt;{"123", "sami", "Test Only"}&lt;BR /&gt;{"123", "samuel", "This is the record I want"}&lt;BR /&gt;{"345", "sharo19", "VICC eassocr"}&lt;BR /&gt;{"678", "pat", "Test2"}&lt;BR /&gt;{"678", "patrick1", "Real Test now"}&lt;BR /&gt;{"321", "sharo19", "VICC eassocr"}&lt;BR /&gt;===============================&lt;BR /&gt;&lt;BR /&gt;OUTPUT NEEDED FROM THE ABOVE INPUT FILE is:&lt;BR /&gt;===========================================&lt;BR /&gt;{"123", "samuel", "This is the record I want"}&lt;BR /&gt;{"345", "sharo19", "VICC eassocr"}&lt;BR /&gt;{"678", "patrick1", "Real Test now"}&lt;BR /&gt;{"321", "sharo19", "VICC eassocr"}&lt;BR /&gt;===========================================&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Sep 2001 16:03:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584699#M856105</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2001-09-25T16:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584700#M856106</link>
      <description>Hi Sam:&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset MYFILE=$1&lt;BR /&gt;awk -F, 'BEGIN {TOG=0;D=$1;S=$0}&lt;BR /&gt;        {if (TOG==1 &amp;amp;&amp;amp; D!=$1)&lt;BR /&gt;                {print S} TOG=1;D=$1;S=$0}&lt;BR /&gt;        END {print S}' $MYFILE&lt;BR /&gt;exit 0&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;Pass your input file as an arguement to the script above and you will get the desired output.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Sep 2001 16:47:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584700#M856106</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-09-25T16:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584701#M856107</link>
      <description>Hi (again) Sam:&lt;BR /&gt;&lt;BR /&gt;Oops. The 'awk' BEGIN rule (although harmless) is superfluous.  Actually no I/O has occured at that point and I should have dropped it, simplfying to:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset MYFILE=$1&lt;BR /&gt;awk -F, '{if (TOG==1 &amp;amp;&amp;amp; D!=$1) {print S} TOG=1;D=$1;S=$0}&lt;BR /&gt;        END {print S}' $MYFILE&lt;BR /&gt;exit 0&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Sep 2001 17:32:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584701#M856107</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-09-25T17:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584702#M856108</link>
      <description>Hi Sam,&lt;BR /&gt;&lt;BR /&gt;Here's another way to do it,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/Begin/&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [[ $# &amp;lt; 1 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "Usage: $0 filename"&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;cat $1 |sort -n |cut -d \" -f 2 |uniq |while read id&lt;BR /&gt;do&lt;BR /&gt;grep "$id" "$inputfile" |tail -1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;/End/&lt;BR /&gt;&lt;BR /&gt;To run it&lt;BR /&gt;script.sh filename&lt;BR /&gt;&lt;BR /&gt;-HTH&lt;BR /&gt;Ramesh</description>
      <pubDate>Tue, 25 Sep 2001 17:44:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584702#M856108</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-09-25T17:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584703#M856109</link>
      <description>Oops, small typo&lt;BR /&gt;This should definitely work&lt;BR /&gt;&lt;BR /&gt;/Begin/ &lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;&lt;BR /&gt;if [[ $# &amp;lt; 1 ]] &lt;BR /&gt;then &lt;BR /&gt;echo "Usage: $0 filename" &lt;BR /&gt;exit 1 &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;cat $1 |sort -n |cut -d \" -f 2 |uniq |while read id &lt;BR /&gt;do &lt;BR /&gt;grep "$id" "$1" |tail -1 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;/End/ &lt;BR /&gt;&lt;BR /&gt;-Regards&lt;BR /&gt;Ramesh</description>
      <pubDate>Tue, 25 Sep 2001 17:46:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584703#M856109</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-09-25T17:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584704#M856110</link>
      <description>cat yourFile |&lt;BR /&gt;awk '{&lt;BR /&gt;  split($0,array,"\"");&lt;BR /&gt;  id=array[2];&lt;BR /&gt;  bigA[id]=$0;&lt;BR /&gt;} END {&lt;BR /&gt;  for ( i in bigA )&lt;BR /&gt;    print bigA[i];&lt;BR /&gt;}'</description>
      <pubDate>Tue, 25 Sep 2001 17:48:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584704#M856110</guid>
      <dc:creator>Curtis Larson_1</dc:creator>
      <dc:date>2001-09-25T17:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: parsing text by scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584705#M856111</link>
      <description>Thanks to James, Ramesh and Curtis.&lt;BR /&gt;All of your script did what I asked for .&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Sep 2001 18:48:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-text-by-scripting/m-p/2584705#M856111</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2001-09-25T18:48:41Z</dc:date>
    </item>
  </channel>
</rss>

