<?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: Shell Script with files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820245#M720892</link>
    <description>Hi (again) Glenn:&lt;BR /&gt;&lt;BR /&gt;You already have raised the rabbit.  By assigning (at least) one post a score of eight (or greater), the rabbit icon appears next to the thread when you refresh the HP-UX familyhome.&lt;BR /&gt;&lt;BR /&gt;BTW, to keep the hounds from your heels, I suggest that you assign 0-10 points to *every* post in this thread.  In that fashion, *your* profile's statistics will show that you have a 100% point assignement rate --- something that seems to get close scrutiny these days ;-)&lt;BR /&gt;&lt;BR /&gt;More importantly, *welcome* to the ITRC forum.  I see that today is your first day.  I'm glad to have been of help.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 07 Oct 2002 20:18:33 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-10-07T20:18:33Z</dc:date>
    <item>
      <title>Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820233#M720880</link>
      <description>I have a Korn shell script the reads a file with multiple record types.  If I find rcd type =455, then I need to add 4 bytes to the end of the record.  &lt;BR /&gt;If the recd type=455 and "abcdef" does not exist on the line, 4 spaces need to be added to the end of the line. &lt;BR /&gt;If the recd type=455 and has "abcdef" on the line, I need to check another file (file2 - with a sorted sequential list of IDs) to see if file1.ID=file2.ID.  If I find a match in file2, the last 4 bytes in file1 should be 'XXYY'.  If there is no match in file2, the last 4 bytes should be 'XXbb' (where bb means spaces).  &lt;BR /&gt;What is the best way to tackle this problem?  I am a novice at UNIX.  I was told that awk may do the trick</description>
      <pubDate>Mon, 07 Oct 2002 14:59:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820233#M720880</guid>
      <dc:creator>Glenn Morton_1</dc:creator>
      <dc:date>2002-10-07T14:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820234#M720881</link>
      <description>You can use ksh or awk or perl.&lt;BR /&gt;&lt;BR /&gt;For (useful) suggested solutions, it would be helpful if you could post samples from file1 and file2.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Mon, 07 Oct 2002 15:19:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820234#M720881</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-10-07T15:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820235#M720882</link>
      <description>Hi Glenn,&lt;BR /&gt;I am not expert in scripting &lt;BR /&gt;As a starting point &lt;BR /&gt;&lt;BR /&gt;read file till end&lt;BR /&gt;if type=455 &lt;BR /&gt;then&lt;BR /&gt;      look for "abcdef"&lt;BR /&gt;         if not found then add 4 space at end&lt;BR /&gt;        if found then&lt;BR /&gt;            open another file&lt;BR /&gt;              match then id. &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;please post sample of files and your sample script if possible. &lt;BR /&gt;This forum has someof great scripter. &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Sachin</description>
      <pubDate>Mon, 07 Oct 2002 17:12:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820235#M720882</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2002-10-07T17:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820236#M720883</link>
      <description>Sorry for the confusion.  It is confusing to me. I'll try to give a good example.&lt;BR /&gt;I am a COBOL programmer, and I don't know how to do this in the Unix environment. Here is the attachment.</description>
      <pubDate>Mon, 07 Oct 2002 17:50:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820236#M720883</guid>
      <dc:creator>Glenn Morton_1</dc:creator>
      <dc:date>2002-10-07T17:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820237#M720884</link>
      <description>Hi Glenn:&lt;BR /&gt;&lt;BR /&gt;'awk' is certainly one way to accomplish this task.  Since your specifications are somewhat vague, I'll provide a sample of what I think you want as a pattern.&lt;BR /&gt;&lt;BR /&gt;The code below assumes a reference file named "/tmp/myref" for matching to your list of "ID"s.  The code assumes that the first field in your input file is matched against this reference list.&lt;BR /&gt;&lt;BR /&gt;I've used "b" to donote blank characters.  Change it to an actual blank (space) if you use this.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk '&lt;BR /&gt;  { if ($0~/455/) {&lt;BR /&gt;      if ($0~/abcdef/) {&lt;BR /&gt;        COMMAND=("grep -q " $1 " /tmp/myref")&lt;BR /&gt;        if (system(COMMAND))&lt;BR /&gt;          {print $0 "XXbb"&lt;BR /&gt;          }&lt;BR /&gt;        else&lt;BR /&gt;          {print $0 "XXYY"&lt;BR /&gt;          }&lt;BR /&gt;        close(COMMAND)&lt;BR /&gt;      }&lt;BR /&gt;    else&lt;BR /&gt;      {print $0"bbbb"&lt;BR /&gt;      }&lt;BR /&gt;  }&lt;BR /&gt;    else&lt;BR /&gt;      {print $0&lt;BR /&gt;      }&lt;BR /&gt;} ' /tmp/myinput &amp;gt; /tmp/myoutput&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Oct 2002 18:14:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820237#M720884</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-07T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820238#M720885</link>
      <description>Hi (again) Glenn:&lt;BR /&gt;&lt;BR /&gt;OK, using your input (call it '/tmp/myinput' and a reference list called '/tmp/myref'), try this modified version:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk '&lt;BR /&gt;  { if ($2~/455/) {&lt;BR /&gt;      if ($0~/abcdef/) {&lt;BR /&gt;        COMMAND=("grep -q " substr($4,4) " /tmp/myref")&lt;BR /&gt;        if (system(COMMAND))&lt;BR /&gt;          {print $0 "XXbb"&lt;BR /&gt;          }&lt;BR /&gt;        else&lt;BR /&gt;          {print $0 "XXYY"&lt;BR /&gt;          }&lt;BR /&gt;        close(COMMAND)&lt;BR /&gt;      }&lt;BR /&gt;    else &lt;BR /&gt;      {print $0"bbbb"&lt;BR /&gt;      }&lt;BR /&gt;  }&lt;BR /&gt;    else&lt;BR /&gt;      {print $0&lt;BR /&gt;      }&lt;BR /&gt;} ' /tmp/myinput&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Oct 2002 18:27:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820238#M720885</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-07T18:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820239#M720886</link>
      <description>Hi (again) Glenn:&lt;BR /&gt;&lt;BR /&gt;OOPS...use this version, please.  The previous post bungled the 'substr':&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk '&lt;BR /&gt;  { if ($2~/455/) {&lt;BR /&gt;      if (substr($4,17,6)=="abcdef") {&lt;BR /&gt;        COMMAND=("grep -q " substr($4,1,4) " /tmp/myref")&lt;BR /&gt;        if (system(COMMAND))&lt;BR /&gt;          {print $0 "XXbb"&lt;BR /&gt;          }&lt;BR /&gt;        else&lt;BR /&gt;          {print $0 "XXYY"&lt;BR /&gt;          }&lt;BR /&gt;        close(COMMAND)&lt;BR /&gt;      }&lt;BR /&gt;    else &lt;BR /&gt;      {print $0"bbbb"&lt;BR /&gt;      }&lt;BR /&gt;  }&lt;BR /&gt;    else&lt;BR /&gt;      {print $0&lt;BR /&gt;      }&lt;BR /&gt;} ' /tmp/myinput&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Oct 2002 18:35:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820239#M720886</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-07T18:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820240#M720887</link>
      <description>Hi Glenn,&lt;BR /&gt;&lt;BR /&gt;See if this fits your requirements. It will save the white spaces at the end of each line.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;sed 's/ /+/g' file1 &amp;gt; tempfile&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;line=`echo $LINE|sed 's/+/ /g'`&lt;BR /&gt;RCD=`echo $line |awk '{print $2}'`&lt;BR /&gt;echo $RCD&lt;BR /&gt;if [ "$RCD" = 455 ]&lt;BR /&gt;then&lt;BR /&gt;echo $line |grep "abcdef" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;IDENT=`echo $line |awk '{print $4}'|cut -c 1-4`&lt;BR /&gt;grep $IDENT file2 &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo $LINE |sed 's/$/XXYY/g' |sed 's/+/ /g' &amp;gt;&amp;gt; output&lt;BR /&gt;else&lt;BR /&gt;echo $LINE |sed 's/$/XX##/g' |sed 's/+/ /g' &amp;gt;&amp;gt; output&lt;BR /&gt;fi&lt;BR /&gt;else&lt;BR /&gt;echo $LINE |sed 's/$/####/g' |sed 's/+/ /g' &amp;gt;&amp;gt; output&lt;BR /&gt;fi        &lt;BR /&gt;else&lt;BR /&gt;echo $LINE |sed 's/+/ /g' &amp;gt;&amp;gt; output&lt;BR /&gt;fi&lt;BR /&gt;done &amp;lt; file1&lt;BR /&gt;&lt;BR /&gt;rm tempfile&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Oct 2002 18:51:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820240#M720887</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-10-07T18:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820241#M720888</link>
      <description>Or with perl (also attached in case the white space gets goofed up):&lt;BR /&gt;&lt;BR /&gt;perl -nle '&lt;BR /&gt;BEGIN   {&lt;BR /&gt;        open (ids, "file2");&lt;BR /&gt;        while (&lt;IDS&gt;) {&lt;BR /&gt;                chomp;&lt;BR /&gt;                $ids{$_} = 1;&lt;BR /&gt;        }&lt;BR /&gt;        }&lt;BR /&gt;if (/^455 /) {&lt;BR /&gt;        if (/ .* (....).*abcdef/) {&lt;BR /&gt;                if (defined $ids{$1}) {&lt;BR /&gt;                        print $_, "XXYY";&lt;BR /&gt;                }&lt;BR /&gt;                else {&lt;BR /&gt;                        print $_, "XX  ";&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        else {&lt;BR /&gt;                print $_, "    ";&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;else {print;}' file1&lt;BR /&gt;&lt;/IDS&gt;</description>
      <pubDate>Mon, 07 Oct 2002 19:21:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820241#M720888</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-10-07T19:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820242#M720889</link>
      <description>Glen,&lt;BR /&gt;&lt;BR /&gt;Here is a short perl program that may do what you want.&lt;BR /&gt;&lt;BR /&gt;open(INP,"&lt;FILE2&gt;&lt;/FILE2&gt;while(&lt;INP&gt;) {&lt;BR /&gt; if (substr($_,0,3) ne "455") { $hold{substr($_,19,4)}=1; }&lt;BR /&gt;}&lt;BR /&gt;close(INP);&lt;BR /&gt;open(INP,"&lt;FILE1&gt;&lt;/FILE1&gt;open(OUT,"&amp;gt;newfile");&lt;BR /&gt;while(&lt;INP&gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt; undef $app; &lt;BR /&gt; $app="    " if substr($_,0,3) eq "455";&lt;BR /&gt; $app="XX  " if substr($_,35,6) eq "abcdefg" and defined $app;&lt;BR /&gt; $app="XXYY" if $hold{substr($_,19,4)} and $app eq "XX  ";&lt;BR /&gt; print OUT $_,$app,"\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;It first reads in file2 and saves the ID for type 455. Then reading in file1 is just a matter of testing your conditions. (you may want to check the offsets I used in the substr function).&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;/INP&gt;&lt;/INP&gt;</description>
      <pubDate>Mon, 07 Oct 2002 19:24:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820242#M720889</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-10-07T19:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820243#M720890</link>
      <description>Thanks for your input.  I believe that I have enough to work with. Special thx to James.</description>
      <pubDate>Mon, 07 Oct 2002 19:48:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820243#M720890</guid>
      <dc:creator>Glenn Morton_1</dc:creator>
      <dc:date>2002-10-07T19:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820244#M720891</link>
      <description>How do I show that I have the Magical Answer? &lt;BR /&gt;How do I get the rabbit to appear?</description>
      <pubDate>Mon, 07 Oct 2002 20:04:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820244#M720891</guid>
      <dc:creator>Glenn Morton_1</dc:creator>
      <dc:date>2002-10-07T20:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820245#M720892</link>
      <description>Hi (again) Glenn:&lt;BR /&gt;&lt;BR /&gt;You already have raised the rabbit.  By assigning (at least) one post a score of eight (or greater), the rabbit icon appears next to the thread when you refresh the HP-UX familyhome.&lt;BR /&gt;&lt;BR /&gt;BTW, to keep the hounds from your heels, I suggest that you assign 0-10 points to *every* post in this thread.  In that fashion, *your* profile's statistics will show that you have a 100% point assignement rate --- something that seems to get close scrutiny these days ;-)&lt;BR /&gt;&lt;BR /&gt;More importantly, *welcome* to the ITRC forum.  I see that today is your first day.  I'm glad to have been of help.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Oct 2002 20:18:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820245#M720892</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-07T20:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script with files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820246#M720893</link>
      <description>&lt;BR /&gt;And yet another way to do it in PERL. Use it this way:&lt;BR /&gt;&lt;BR /&gt;script ref-file &amp;lt; data-file &amp;gt; new-file</description>
      <pubDate>Mon, 07 Oct 2002 20:49:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-with-files/m-p/2820246#M720893</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-10-07T20:49:41Z</dc:date>
    </item>
  </channel>
</rss>

