<?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 in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111474#M91653</link>
    <description>My prev post is not great as it stripped out my whitespace.&lt;BR /&gt;&lt;BR /&gt;But in my example theres 2 fields in FileA and 4 fields in FileB.</description>
    <pubDate>Fri, 30 May 2008 09:27:40 GMT</pubDate>
    <dc:creator>OFC_EDM</dc:creator>
    <dc:date>2008-05-30T09:27:40Z</dc:date>
    <item>
      <title>File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111471#M91650</link>
      <description>Hi,&lt;BR /&gt;I want to read one file and fetch data from other file. please see the example&lt;BR /&gt;file A contain employee id and file B contain employee details along with employee id.&lt;BR /&gt;So i want to fetch record from file B by reading file A.&lt;BR /&gt;&lt;BR /&gt;Thanks in advanced.</description>
      <pubDate>Fri, 30 May 2008 08:48:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111471#M91650</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-05-30T08:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111472#M91651</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Have a look at the "join" command (man join),&lt;BR /&gt;</description>
      <pubDate>Fri, 30 May 2008 08:58:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111472#M91651</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2008-05-30T08:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111473#M91652</link>
      <description>File A&lt;BR /&gt;-------------------&lt;BR /&gt;employeeID  otherinfo&lt;BR /&gt;&lt;BR /&gt;File B&lt;BR /&gt;-------------------&lt;BR /&gt;employeeID firstname lastname favouritehobby&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILE a=""&gt; | \&lt;BR /&gt;while read ID OTHERSTUFF&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;grep "${ID}" /path/to/FileB&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;My syntax may not be bang on.  But this will simply read File A line by line and put the first field into variable ID.&lt;BR /&gt;&lt;BR /&gt;Then it greps the ID from FileB.&lt;BR /&gt;&lt;BR /&gt;This will just display the lines to the screen.  You can redirect it to a file if you like.&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILENAME a=""&gt; | \&lt;BR /&gt;while read ID OTHERSTUFF&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;grep "${ID}" /path/to/FileB  &amp;gt;&amp;gt; tonewfile.txt&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;And then there's the join command.  I use the method above because it reads each line into variables (whitespace separated).  I can then customize the order of the fields when creating output quite easily.  Because the data is in variables.&lt;BR /&gt;&lt;BR /&gt;You can make this more advanced by using sed as well.  But if a simple grep will do the trick I use that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 30 May 2008 09:25:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111473#M91652</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-05-30T09:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111474#M91653</link>
      <description>My prev post is not great as it stripped out my whitespace.&lt;BR /&gt;&lt;BR /&gt;But in my example theres 2 fields in FileA and 4 fields in FileB.</description>
      <pubDate>Fri, 30 May 2008 09:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111474#M91653</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-05-30T09:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111475#M91654</link>
      <description>Thnaks Kevin for quick response.</description>
      <pubDate>Fri, 30 May 2008 09:53:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111475#M91654</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-05-30T09:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111476#M91655</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Here's another way:&lt;BR /&gt;&lt;BR /&gt;# cat fileA&lt;BR /&gt;1&lt;BR /&gt;3&lt;BR /&gt;5&lt;BR /&gt;7&lt;BR /&gt;9&lt;BR /&gt;&lt;BR /&gt;# cat fileB&lt;BR /&gt;a 1&lt;BR /&gt;b 2&lt;BR /&gt;e 5&lt;BR /&gt;f 6&lt;BR /&gt;i 9&lt;BR /&gt;&lt;BR /&gt;# grep -f fileA fileB&lt;BR /&gt;a 1&lt;BR /&gt;e 5&lt;BR /&gt;i 9&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 30 May 2008 10:39:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111476#M91655</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-30T10:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111477#M91656</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Of course there is several ways to solve a problem but I would prefer "join" in a case like this.&lt;BR /&gt;&lt;BR /&gt;One reason is that "join" can easily handle a "one to many" relation ( one line in the first file matches several lines in the second file).&lt;BR /&gt;&lt;BR /&gt;Another reason is that both files is only read once (if using "grep", the entire file 2 will be read for every line in file1).&lt;BR /&gt;&lt;BR /&gt;The output from, join can be composed from any of the filds in the two files but, if you need post-processing (e.g. headers, summary) you can pipe the output to "awk".</description>
      <pubDate>Fri, 30 May 2008 11:30:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111477#M91656</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2008-05-30T11:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111478#M91657</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Indeed TMTOWTDI&lt;BR /&gt;&lt;BR /&gt;A better definition of the two files; their size; their fields; their field delimiters; their order (sorted or unsorted); whether or not the output order needs to match that of the input; whether or not duplicate matches should be discarded or output; all of this would lead to a better answer.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 30 May 2008 11:45:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111478#M91657</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-30T11:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: File Handling</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111479#M91658</link>
      <description>Thanks everybody.</description>
      <pubDate>Tue, 03 Jun 2008 03:54:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-handling/m-p/5111479#M91658</guid>
      <dc:creator>Panpalia</dc:creator>
      <dc:date>2008-06-03T03:54:25Z</dc:date>
    </item>
  </channel>
</rss>

