<?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: Trying to extract data from multiple files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156657#M158580</link>
    <description>Here's one method that takes advantage of the shell's read command.&lt;BR /&gt;&lt;BR /&gt;read V1 V2 would read&lt;BR /&gt;#DESCRIPTION This is a test&lt;BR /&gt;and stuff "#DESCRIPTION" into V1 and everything else (because V2 is the last variable) into V2.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;FILES="myfile1 myfile2 myfile3"&lt;BR /&gt;echo "FILENAME\tDESCRIPTION"&lt;BR /&gt;echo&lt;BR /&gt;for FILE in ${FILES}&lt;BR /&gt;  do&lt;BR /&gt;     grep -E -q "^#DESCRIPTION" ${FILE}&lt;BR /&gt;     STAT=${?}&lt;BR /&gt;     if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;       then #found&lt;BR /&gt;         grep -E "^#DESCRIPTION" ${FILE} | while read V1 V2&lt;BR /&gt;           do&lt;BR /&gt;              echo "${FILE}\t${V2}"&lt;BR /&gt;           done&lt;BR /&gt;       fi&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;Note that we intentionally ignore ${V1} because it contains the known string "#DESCRIPTION".&lt;BR /&gt;</description>
    <pubDate>Mon, 05 Jan 2004 18:27:22 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2004-01-05T18:27:22Z</dc:date>
    <item>
      <title>Trying to extract data from multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156655#M158578</link>
      <description>I'm trying to write a script that will extract several lines of information from multiple ascii files and then parse it to a single file.&lt;BR /&gt;&lt;BR /&gt;I'm trying to get the FILENAME of the file and 1 or more lines that start off with "#Description:". The "Description" lines are not always on the same line number. I want the output file to read something like:&lt;BR /&gt;&lt;BR /&gt;FILENAME        DESCRIPTION&lt;BR /&gt;&lt;BR /&gt;filename1       does whatever&lt;BR /&gt;filename2       checks whatever &lt;BR /&gt;                also does whatever&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Ken</description>
      <pubDate>Mon, 05 Jan 2004 18:03:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156655#M158578</guid>
      <dc:creator>Ken Opersteny</dc:creator>
      <dc:date>2004-01-05T18:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract data from multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156656#M158579</link>
      <description>A simple "grep"-&lt;BR /&gt; &lt;BR /&gt;grep "^#Description" yourfiles*&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 18:11:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156656#M158579</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-01-05T18:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract data from multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156657#M158580</link>
      <description>Here's one method that takes advantage of the shell's read command.&lt;BR /&gt;&lt;BR /&gt;read V1 V2 would read&lt;BR /&gt;#DESCRIPTION This is a test&lt;BR /&gt;and stuff "#DESCRIPTION" into V1 and everything else (because V2 is the last variable) into V2.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;FILES="myfile1 myfile2 myfile3"&lt;BR /&gt;echo "FILENAME\tDESCRIPTION"&lt;BR /&gt;echo&lt;BR /&gt;for FILE in ${FILES}&lt;BR /&gt;  do&lt;BR /&gt;     grep -E -q "^#DESCRIPTION" ${FILE}&lt;BR /&gt;     STAT=${?}&lt;BR /&gt;     if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;       then #found&lt;BR /&gt;         grep -E "^#DESCRIPTION" ${FILE} | while read V1 V2&lt;BR /&gt;           do&lt;BR /&gt;              echo "${FILE}\t${V2}"&lt;BR /&gt;           done&lt;BR /&gt;       fi&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;Note that we intentionally ignore ${V1} because it contains the known string "#DESCRIPTION".&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 18:27:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156657#M158580</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-05T18:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract data from multiple files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156658#M158581</link>
      <description>Thanks for the help.&lt;BR /&gt;&lt;BR /&gt;Clay's script is exactly what I was trying to do.</description>
      <pubDate>Tue, 06 Jan 2004 10:09:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trying-to-extract-data-from-multiple-files/m-p/3156658#M158581</guid>
      <dc:creator>Ken Opersteny</dc:creator>
      <dc:date>2004-01-06T10:09:37Z</dc:date>
    </item>
  </channel>
</rss>

