<?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: merging lines in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919315#M91065</link>
    <description>I am assuming, this day in age, you have deployed ssh and have one central, secure node, where you can ssh to the others without having to type a pasword or passphrase. &lt;BR /&gt;&lt;BR /&gt;Another assumption here: whichever directory you are dumping these *.out files into, does not have any outher files with .out extension except the patch lists&lt;BR /&gt;&lt;BR /&gt;Having said that and assuming you have such a node, from this secure management node:&lt;BR /&gt;&lt;BR /&gt;-----Code Begin-----&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RESULTSFILE=pick_a_filename_here&lt;BR /&gt;####################################&lt;BR /&gt;# prepare the header line&lt;BR /&gt;####################################&lt;BR /&gt;printf "PATCH\t" &amp;gt; $RESULTSFILE&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;printf "${host}\t" &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;done&lt;BR /&gt;printf "\n" &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;####################################&lt;BR /&gt;# collect patches lists from servers&lt;BR /&gt;####################################&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;ssh ${host} "swlist -l product | grep PH | awk {'print $1'}" &amp;gt; ${host}.out&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;####################################&lt;BR /&gt;# create the RESULTSFILE&lt;BR /&gt;####################################&lt;BR /&gt;for file in *.out&lt;BR /&gt;cat $file &amp;gt;&amp;gt; templist&lt;BR /&gt;done&lt;BR /&gt;sort templist|uniq &amp;gt; patchlist&lt;BR /&gt;&lt;BR /&gt;for patch in `cat patchlist`&lt;BR /&gt;do&lt;BR /&gt;printf $patch &amp;gt; pline&lt;BR /&gt;&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;grep -q $patch ${host}.out; r=${?}&lt;BR /&gt;if [ $r -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;printf "yes\t" &amp;gt;&amp;gt; pline&lt;BR /&gt;else&lt;BR /&gt;printf "no\t" &amp;gt;&amp;gt; pline&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat pline &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;-----Code End-----&lt;BR /&gt;&lt;BR /&gt;This is the type of situation that I would love to have this fixed character spacing code segment insertion feature that we are supposed to have now (but seems like nobody is aware of how to use it yet) The code would have looked much cooler with indentation.</description>
    <pubDate>Thu, 18 Aug 2005 15:53:54 GMT</pubDate>
    <dc:creator>Mel Burslan</dc:creator>
    <dc:date>2005-08-18T15:53:54Z</dc:date>
    <item>
      <title>merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919306#M91056</link>
      <description>Done this before but am drawing a blank.&lt;BR /&gt;&lt;BR /&gt;I'm listing all the patches on 3 separate servers into 3 files.  1D 9D and 1A&lt;BR /&gt;&lt;BR /&gt;For simplicity we'll say the files have the following content.&lt;BR /&gt;&lt;BR /&gt;File 1D.out      9D.out       1A.out&lt;BR /&gt;     -------     --------     ---------&lt;BR /&gt;     patchA      patchA       patchB&lt;BR /&gt;     patchB      patchC       patchC&lt;BR /&gt;&lt;BR /&gt;I want the output to be:  (FS=| and each colums 2-4 represent if the patch was found in a source file.&lt;BR /&gt;&lt;BR /&gt;patchA|yes|yes|no  # Found in 1D,9D and not 1A&lt;BR /&gt;patchB|yes|no|yes&lt;BR /&gt;patchC|yes|no|no&lt;BR /&gt;&lt;BR /&gt;Where "yes" and "no" represent if the patch was found in the source file.&lt;BR /&gt;&lt;BR /&gt;I want to write this in POSIX / KSH and not Perl since the folks I work with aren't Perl programmers.&lt;BR /&gt;&lt;BR /&gt;How can I merge these records to achieve this result?&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Aug 2005 13:39:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919306#M91056</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2005-08-18T13:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919307#M91057</link>
      <description>If not Perl, then how about awk?&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Thu, 18 Aug 2005 13:52:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919307#M91057</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-08-18T13:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919308#M91058</link>
      <description>#!/usr/bin/sh&lt;BR /&gt;cat 1D 9D 1A |sort |uniq |while read PATCH ;do&lt;BR /&gt;   LINE="$PATCH"&lt;BR /&gt;   if [ -n "`grep $PATCH 1D`" ] ;then&lt;BR /&gt;       LINE="$LINE|yes"&lt;BR /&gt;   else&lt;BR /&gt;       LINE="$LINE|no"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ -n "`grep $PATCH 9D`" ] ;then&lt;BR /&gt;       LINE="$LINE|yes"&lt;BR /&gt;   else&lt;BR /&gt;       LINE="$LINE|no"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ -n "`grep $PATCH 1A`" ] ;then&lt;BR /&gt;       LINE="$LINE|yes"&lt;BR /&gt;   else&lt;BR /&gt;       LINE="$LINE|no"&lt;BR /&gt;   fi&lt;BR /&gt;   print $LINE&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Aug 2005 14:04:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919308#M91058</guid>
      <dc:creator>Alan Meyer_4</dc:creator>
      <dc:date>2005-08-18T14:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919309#M91059</link>
      <description>Thanks for the ideas.  I'm going to try them out.</description>
      <pubDate>Thu, 18 Aug 2005 14:07:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919309#M91059</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2005-08-18T14:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919310#M91060</link>
      <description>RESULTSFILE=pick_a_filename_here&lt;BR /&gt;cat 1D.out 9D.out 1A.out | sort | uniq &amp;gt; patchlist.out&lt;BR /&gt;&lt;BR /&gt;for p in `cat patchlist.out`&lt;BR /&gt;do&lt;BR /&gt;grep -q $p 1D.out; r1=${?}&lt;BR /&gt;grep -q $p 9D.out; r2=${?}&lt;BR /&gt;grep -q $p 1A.out; r3=${?}&lt;BR /&gt;r1D="no";r9D="no";r1A="no"&lt;BR /&gt;&lt;BR /&gt;if [ $r1 -eq 0 ]&lt;BR /&gt;then &lt;BR /&gt;r1D="yes"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $r2 -eq 0 ]&lt;BR /&gt;then &lt;BR /&gt;r9D="yes"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $r3 -eq 0 ]&lt;BR /&gt;then &lt;BR /&gt;r1A="yes"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;echo $p"\t"$r1D"\t"$r9D"\t"$r1A &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Aug 2005 14:10:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919310#M91060</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-08-18T14:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919311#M91061</link>
      <description>#!/usr/bin/ksh&lt;BR /&gt;#Script for patch check on different hosts&lt;BR /&gt;&lt;BR /&gt;patch_to_check=$1&lt;BR /&gt;stat=$?&lt;BR /&gt;echo ${patch_to_check} &amp;gt; /tmp/${patch_to_check}&lt;BR /&gt;&lt;BR /&gt;for i in 1D 9D 1A&lt;BR /&gt;do&lt;BR /&gt;swlist ${patch_to_check} @ ${i}&lt;BR /&gt;if [[ ${stat} -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;echo "yes" &amp;gt; /tmp/${i}&lt;BR /&gt;else&lt;BR /&gt;echo "no" &amp;gt; /tmp/${i}&lt;BR /&gt;done&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;echo "$(cat /tmp/${patch_to_check})|$(cat /tmp/1D)|$(cat /tmp/9D)|$(cat /tmp/1A)"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Not tested, but should work.</description>
      <pubDate>Thu, 18 Aug 2005 14:11:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919311#M91061</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-08-18T14:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919312#M91062</link>
      <description>Kevin,&lt;BR /&gt;&lt;BR /&gt;Attached a shell script (POSIX) for merging lines in order to compare patches from the three different servers.&lt;BR /&gt;&lt;BR /&gt;regards!!!</description>
      <pubDate>Thu, 18 Aug 2005 14:46:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919312#M91062</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-08-18T14:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919313#M91063</link>
      <description>Thanks for the ideas.&lt;BR /&gt;&lt;BR /&gt;I'm now using all your ideas to add some extra functionality.&lt;BR /&gt;&lt;BR /&gt;I want to have all the hostnames in a source file.&lt;BR /&gt;&lt;BR /&gt;That way I can just modify that file and create a report on a different set of servers.&lt;BR /&gt;&lt;BR /&gt;I'll let you know when done and will then assign points.&lt;BR /&gt;&lt;BR /&gt;If you have tips on how to adjust posted ideas to read servers from a file and then compare the patches that would be great too.</description>
      <pubDate>Thu, 18 Aug 2005 15:25:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919313#M91063</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2005-08-18T15:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919314#M91064</link>
      <description>Shouldn't be hard if you provide the command you're using for generating the patch list on the servers you are thinking about doing this on. Actually it will be a simple while loop at the top of whatever script you're using:&lt;BR /&gt;&lt;BR /&gt;================================================&lt;BR /&gt;cat &lt;SERVER_FILE&gt; | while read Server&lt;BR /&gt;do&lt;BR /&gt;   &lt;CMDS&gt;&lt;BR /&gt;   &lt;GENERATE_PATCH_REPORT&gt; $Server.out&amp;gt;&lt;BR /&gt;   &lt;CMDS&gt;&lt;BR /&gt;done&lt;BR /&gt;.&lt;BR /&gt;&lt;REST_OF_SCRIPT&gt;&lt;/REST_OF_SCRIPT&gt;.&lt;BR /&gt;================================================&lt;BR /&gt;cheers!!!&lt;/CMDS&gt;&lt;/GENERATE_PATCH_REPORT&gt;&lt;/CMDS&gt;&lt;/SERVER_FILE&gt;</description>
      <pubDate>Thu, 18 Aug 2005 15:41:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919314#M91064</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-08-18T15:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919315#M91065</link>
      <description>I am assuming, this day in age, you have deployed ssh and have one central, secure node, where you can ssh to the others without having to type a pasword or passphrase. &lt;BR /&gt;&lt;BR /&gt;Another assumption here: whichever directory you are dumping these *.out files into, does not have any outher files with .out extension except the patch lists&lt;BR /&gt;&lt;BR /&gt;Having said that and assuming you have such a node, from this secure management node:&lt;BR /&gt;&lt;BR /&gt;-----Code Begin-----&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RESULTSFILE=pick_a_filename_here&lt;BR /&gt;####################################&lt;BR /&gt;# prepare the header line&lt;BR /&gt;####################################&lt;BR /&gt;printf "PATCH\t" &amp;gt; $RESULTSFILE&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;printf "${host}\t" &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;done&lt;BR /&gt;printf "\n" &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;####################################&lt;BR /&gt;# collect patches lists from servers&lt;BR /&gt;####################################&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;ssh ${host} "swlist -l product | grep PH | awk {'print $1'}" &amp;gt; ${host}.out&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;####################################&lt;BR /&gt;# create the RESULTSFILE&lt;BR /&gt;####################################&lt;BR /&gt;for file in *.out&lt;BR /&gt;cat $file &amp;gt;&amp;gt; templist&lt;BR /&gt;done&lt;BR /&gt;sort templist|uniq &amp;gt; patchlist&lt;BR /&gt;&lt;BR /&gt;for patch in `cat patchlist`&lt;BR /&gt;do&lt;BR /&gt;printf $patch &amp;gt; pline&lt;BR /&gt;&lt;BR /&gt;for host in `cat myhostsfile`&lt;BR /&gt;do&lt;BR /&gt;grep -q $patch ${host}.out; r=${?}&lt;BR /&gt;if [ $r -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;printf "yes\t" &amp;gt;&amp;gt; pline&lt;BR /&gt;else&lt;BR /&gt;printf "no\t" &amp;gt;&amp;gt; pline&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat pline &amp;gt;&amp;gt; $RESULTSFILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;-----Code End-----&lt;BR /&gt;&lt;BR /&gt;This is the type of situation that I would love to have this fixed character spacing code segment insertion feature that we are supposed to have now (but seems like nobody is aware of how to use it yet) The code would have looked much cooler with indentation.</description>
      <pubDate>Thu, 18 Aug 2005 15:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919315#M91065</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-08-18T15:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: merging lines</title>
      <link>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919316#M91066</link>
      <description>Used ideas to develop script which is posted.</description>
      <pubDate>Thu, 17 Apr 2008 10:42:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/merging-lines/m-p/4919316#M91066</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-04-17T10:42:07Z</dc:date>
    </item>
  </channel>
</rss>

