<?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: File handling to fetch records in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111959#M91691</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you thank everyone: why not submits points to them ;-) ?&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
    <pubDate>Wed, 04 Jun 2008 11:14:37 GMT</pubDate>
    <dc:creator>Peter Nikitka</dc:creator>
    <dc:date>2008-06-04T11:14:37Z</dc:date>
    <item>
      <title>File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111946#M91678</link>
      <description>Hi,&lt;BR /&gt;I need to fetch records from the file by checking some condition. Please find the sample of records in the file.&lt;BR /&gt;&lt;BR /&gt;I/P file &lt;BR /&gt;0350000000013502400107395824*Pamela Anne Lentine*Calvary Electric*****Lentine, Pamela Anne**45 ----first records end &lt;BR /&gt;0429000000013702600468749296*GESCO ASESORIA DE EMPRESAS, SL********PASEO DE ALMERIA - PLT 2 63**ALMERIA**1404**ALMERIA**04001&lt;BR /&gt;*SPAIN*693*3***---second records end &lt;BR /&gt;0725000000013802800899116768*AVG SiderM-#rgia Ltda.*AVG SiderM-#rgia*Siderurgica Ita Min Ltda*AVG Siderurgia Ltda*A V G Sider&lt;BR /&gt;urgia Ltda****Rua GrM-Fo ---third records end &lt;BR /&gt;Now I want to fetch only records from the file whose first five fields must be greater then 0500.&lt;BR /&gt;&lt;BR /&gt;So my o/p file should contains following records &lt;BR /&gt;&lt;BR /&gt;O/P&lt;BR /&gt;0725000000013802800899116768*AVG SiderM-#rgia Ltda.*AVG SiderM-#rgia*Siderurgica Ita Min Ltda*AVG Siderurgia Ltda*A V G Sider&lt;BR /&gt;urgia Ltda****Rua GrM-Fo &lt;BR /&gt;Logically i need to cut first five fields then compare whether it's greater then 0500 if yes fetch the whole records or read next records. but i unable to put above logic syntactically. &lt;BR /&gt;&lt;BR /&gt;Could you please provide me the commands and if possible syntax as well .</description>
      <pubDate>Tue, 03 Jun 2008 03:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111946#M91678</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-03T03:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111947#M91679</link>
      <description>&lt;!--!*#--&gt;You don't have any field delimiters.  Also you'll need to better tell us where records end.  I.e. attach a sample file or make the records shorter/simpler.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;i need to cut first five fields&lt;BR /&gt;&lt;BR /&gt;Did you mean the first 4 columns/bytes?&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;value1 = substr($0, 1, 4)&lt;BR /&gt;if (value &amp;lt;= 500)&lt;BR /&gt;   next&lt;BR /&gt;print $0&lt;BR /&gt;} file</description>
      <pubDate>Tue, 03 Jun 2008 05:01:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111947#M91679</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-06-03T05:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111948#M91680</link>
      <description>Oops, these should have the same name:&lt;BR /&gt;value1 = substr($0, 1, 4)&lt;BR /&gt;if (value1 &amp;lt;= 500)</description>
      <pubDate>Tue, 03 Jun 2008 05:37:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111948#M91680</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-06-03T05:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111949#M91681</link>
      <description>Hi There is no field delimiter but we can add.The length of records are variable in size. please find the sample of records in first post.</description>
      <pubDate>Tue, 03 Jun 2008 09:11:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111949#M91681</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-03T09:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111950#M91682</link>
      <description>Need some clarification&lt;BR /&gt;&lt;BR /&gt;Is this record one continuous line with a NewLine at the end?&lt;BR /&gt;&lt;BR /&gt;0350000000013502400107395824*Pamela Anne Lentine*Calvary Electric*****Lentine, Pamela Anne**45 ----first records end &lt;BR /&gt;&lt;BR /&gt;Or are there mulitiple Newlines?&lt;BR /&gt;&lt;BR /&gt;As well do you need to just compare the first four characters 0350 against 0500?</description>
      <pubDate>Tue, 03 Jun 2008 09:47:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111950#M91682</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-06-03T09:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111951#M91683</link>
      <description>&amp;gt;&amp;gt; Logically i need to cut first five fields then compare &lt;BR /&gt;&lt;BR /&gt;You write 'five fields' twice, but the text suggest '4 characters'. Was there a leading space which dissapeard in teh web page formatting?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;  if yes fetch the whole records or read next records&lt;BR /&gt;&lt;BR /&gt;You write "if ... do this or do that"&lt;BR /&gt;Did you mean "if ... do this else to that" ?&lt;BR /&gt;&lt;BR /&gt;A solution might be:&lt;BR /&gt;&lt;BR /&gt;$ awk '0+substr($0,1,4) &amp;gt; 500' input-file&lt;BR /&gt;&lt;BR /&gt;- The "0 + " forces the value to become numeric for comparison. &lt;BR /&gt;- The empty action defaults to 'print current line'.&lt;BR /&gt;- awk always loops through all records.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Jun 2008 10:57:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111951#M91683</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-06-03T10:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111952#M91684</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Judging from what you posted for sample data, it would appear that your record delimiter is simply a newline.  Thus:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print if substr($_,0,4) &amp;gt;= 500' file&lt;BR /&gt;&lt;BR /&gt;...would print records whose first (zero-relative) column for four characters is greater or equal to 500.&lt;BR /&gt;&lt;BR /&gt;*PLEASE* also read:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You have answers to previous questions that you have not yet evaluated.  These questions of yours can be found by looking at your profile:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1236026" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1236026&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1236353" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1236353&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Providing feedback to the responses to your questions helps the community at large determine which answers solved your problem.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Jun 2008 10:58:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111952#M91684</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-06-03T10:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111953#M91685</link>
      <description>Thanks everyone for your quick reply.&lt;BR /&gt;&lt;BR /&gt;Kevin - The new records start with new line. There is no multiple new line.I need to compare only first  five byte as mentioned by you but need to fetch record if condition is true.&lt;BR /&gt;&lt;BR /&gt;Hein van den Heuvel  -   i need to check first five field (0350) if it's greater then 500 then fetch the complete records.</description>
      <pubDate>Tue, 03 Jun 2008 11:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111953#M91685</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-03T11:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111954#M91686</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you seem to consider Heins solutions as incomplete - why?&lt;BR /&gt;Perhaps:&lt;BR /&gt;1) You stated 'greater than 0500' - this leads to '&amp;gt;'. But because you want to get a line starting 0500, you mean '&amp;gt;=' .&lt;BR /&gt;&lt;BR /&gt;2) The first *five* bytes for the first line seem '03500' to me - not '0350' as you told us:&lt;BR /&gt;Either that are only four bytes or your string is incomplete. 1) + 2) may lead to&lt;BR /&gt;awk '0+substr($0,1,5) &amp;gt;= 5000'&lt;BR /&gt;&lt;BR /&gt;3) The first '0' - is it used to get an octal representation of a number or is it just used to fill the record?&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 03 Jun 2008 14:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111954#M91686</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2008-06-03T14:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111955#M91687</link>
      <description>&amp;gt;There is no field delimiter but we can add.&lt;BR /&gt;&lt;BR /&gt;You don't need to add but you do need to say where they begin and end.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;please find the sample of records in first post.&lt;BR /&gt;&lt;BR /&gt;As I mentioned, this wasn't good enough.&lt;BR /&gt;You need to attach a file and give definition of your record "key".&lt;BR /&gt;&lt;BR /&gt;&amp;gt;MK: 3) The first '0' - is it used to get an octal representation of a number or is it just used to fill the record?&lt;BR /&gt;&lt;BR /&gt;Only broken C does that octal junk.</description>
      <pubDate>Tue, 03 Jun 2008 17:08:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111955#M91687</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-06-03T17:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111956#M91688</link>
      <description>Once again Thanks everyone.&lt;BR /&gt;The following answer solve my issue.&lt;BR /&gt;$awk '0+substr($0,1,4)&amp;gt;500' filename&lt;BR /&gt;Anyone please explain how this command work.</description>
      <pubDate>Wed, 04 Jun 2008 04:01:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111956#M91688</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-04T04:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111957#M91689</link>
      <description>$awk '0+substr($0,1,4)&amp;gt;500' filename&lt;BR /&gt;&amp;gt;Anyone please explain how this command work&lt;BR /&gt;&lt;BR /&gt;Hein already did.  If the first 4 chars are &amp;gt; 500 (the pattern) then print the record (the action).&lt;BR /&gt;If that's too cryptic look at my awk solution where the steps are explicit as in a procedural language.</description>
      <pubDate>Wed, 04 Jun 2008 05:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111957#M91689</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-06-04T05:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111958#M91690</link>
      <description>I got the right solution.</description>
      <pubDate>Wed, 04 Jun 2008 07:13:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111958#M91690</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-04T07:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: File handling to fetch records</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111959#M91691</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you thank everyone: why not submits points to them ;-) ?&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 04 Jun 2008 11:14:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling-to-fetch-records/m-p/5111959#M91691</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2008-06-04T11:14:37Z</dc:date>
    </item>
  </channel>
</rss>

