<?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: need a script to assign in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026071#M97476</link>
    <description>May be didn't explain well. Need to pass these variables in a command.&lt;BR /&gt;&lt;BR /&gt;like:&lt;BR /&gt;&lt;BR /&gt;command -H &lt;FILE1 variable=""&gt; -I &lt;FILE2 variable=""&gt;&lt;BR /&gt;&lt;BR /&gt;so that it will take 1st variable from 1st file and 1st variable in 2nd file to execute command.&lt;BR /&gt;&lt;BR /&gt;thanks.&lt;/FILE2&gt;&lt;/FILE1&gt;</description>
    <pubDate>Thu, 01 Feb 2007 12:25:11 GMT</pubDate>
    <dc:creator>IT_2007</dc:creator>
    <dc:date>2007-02-01T12:25:11Z</dc:date>
    <item>
      <title>need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026068#M97473</link>
      <description>File1 has:&lt;BR /&gt;&lt;BR /&gt;ABC&lt;BR /&gt;DCF&lt;BR /&gt;GRF&lt;BR /&gt;&lt;BR /&gt;File2 has:&lt;BR /&gt;&lt;BR /&gt;4&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Want output should look like:&lt;BR /&gt;&lt;BR /&gt;ABC  4&lt;BR /&gt;DCF  7&lt;BR /&gt;GRF  8&lt;BR /&gt;&lt;BR /&gt;thanks.</description>
      <pubDate>Thu, 01 Feb 2007 11:44:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026068#M97473</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2007-02-01T11:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026069#M97474</link>
      <description>&lt;!--!*#--&gt;Use the 'paste' command.&lt;BR /&gt;&lt;BR /&gt;# man paste&lt;BR /&gt;&lt;BR /&gt;for more info.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# cat file1&lt;BR /&gt;abc&lt;BR /&gt;def&lt;BR /&gt;ghi&lt;BR /&gt;&lt;BR /&gt;# cat file2&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;# paste file1 file2 &amp;gt; file3&lt;BR /&gt;&lt;BR /&gt;# cat file3&lt;BR /&gt;abc 4&lt;BR /&gt;def 5&lt;BR /&gt;ghi 6</description>
      <pubDate>Thu, 01 Feb 2007 11:53:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026069#M97474</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-02-01T11:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026070#M97475</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;note, that the default delimiter of 'paste' is TAB character - use&lt;BR /&gt;paste -d' ' file1 file2 ...&lt;BR /&gt;&lt;BR /&gt;to get 'real' blank.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 01 Feb 2007 12:24:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026070#M97475</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-02-01T12:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026071#M97476</link>
      <description>May be didn't explain well. Need to pass these variables in a command.&lt;BR /&gt;&lt;BR /&gt;like:&lt;BR /&gt;&lt;BR /&gt;command -H &lt;FILE1 variable=""&gt; -I &lt;FILE2 variable=""&gt;&lt;BR /&gt;&lt;BR /&gt;so that it will take 1st variable from 1st file and 1st variable in 2nd file to execute command.&lt;BR /&gt;&lt;BR /&gt;thanks.&lt;/FILE2&gt;&lt;/FILE1&gt;</description>
      <pubDate>Thu, 01 Feb 2007 12:25:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026071#M97476</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2007-02-01T12:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026072#M97477</link>
      <description>I agree; you didn't explain very well.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;paste file1 file2 | while read A B&lt;BR /&gt;  do&lt;BR /&gt;     command -H ${A} -I ${B}&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Feb 2007 13:17:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026072#M97477</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-01T13:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026073#M97478</link>
      <description>&lt;!--!*#--&gt;&amp;gt;May be didn't explain well. Need to pass these variables in a command.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;like:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;command -H &lt;FILE1 variable=""&gt; -I &lt;FILE2 variable=""&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;so that it will take 1st variable from 1st file and 1st variable in 2nd file to &amp;gt;execute command.&lt;BR /&gt;&lt;BR /&gt;Try the shell script below which uses the coprocess functionality of sh-posix(1):&lt;BR /&gt;==============================================================&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;cat file1 |&amp;amp;&lt;BR /&gt;&lt;BR /&gt;exec 3&amp;gt;&amp;amp;p; exec 4&amp;lt;&amp;amp;p&lt;BR /&gt;&lt;BR /&gt;cat file2 |&amp;amp;&lt;BR /&gt;&lt;BR /&gt;exec 5&amp;gt;&amp;amp;p; exec 6&amp;lt;&amp;amp;p&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;  read -u4 file1var1 &amp;amp;&amp;amp; read -u6 file2var1&lt;BR /&gt;  &lt;BR /&gt;  if [[ -z $file1var1 || -z $file2var1 ]]; then&lt;BR /&gt;     break&lt;BR /&gt;  else&lt;BR /&gt;     echo "command -H $file1var1 -I $file2var1"&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;done&lt;/FILE2&gt;&lt;/FILE1&gt;</description>
      <pubDate>Thu, 01 Feb 2007 13:25:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026073#M97478</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-02-01T13:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026074#M97479</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;a general approach for this type of problem is to handle with arrays:&lt;BR /&gt;&lt;BR /&gt;In ksh syntax:&lt;BR /&gt;set -A A 'aa bb cc'&lt;BR /&gt;set -A B '11 22 33'&lt;BR /&gt;typeset -i i=-1&lt;BR /&gt;while [ i+=1 -lt ${#A[*]} ]&lt;BR /&gt;do print $i: ${A[i]} ${B[i]}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;will produce&lt;BR /&gt;0: aa 11&lt;BR /&gt;1: bb 22&lt;BR /&gt;2: cc 33&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 01 Feb 2007 13:30:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026074#M97479</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-02-01T13:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026075#M97480</link>
      <description>&lt;BR /&gt;Here is a one-liner with awk.&lt;BR /&gt;It uses the main loop to read file 1 into $0.&lt;BR /&gt;Then for every loop it reads a line from file2 into a variable to be passde with $0 to the command (here: echo)&lt;BR /&gt;&lt;BR /&gt;#awk '{getline f2 &amp;lt; "file2"; system ("echo " $0 " " f2)}' file1&lt;BR /&gt;abc 4&lt;BR /&gt;def 5&lt;BR /&gt;ghi 6&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is an array style solution with perl.&lt;BR /&gt;It sucks up each file into an array, chops of teh newlines, calls teh comamdn for each entry in the first array, passing both:&lt;BR /&gt;&lt;BR /&gt;perl -e 'open F,shift;@f1=&lt;F&gt;; open F,shift;@f2=&lt;F&gt;; chomp @f1; chomp @f2; for $i (0..@f1){ system("echo  $f1[$i] $f2[$i]")  }' file1 file2&lt;BR /&gt;abc 4&lt;BR /&gt;def 5&lt;BR /&gt;ghi 6&lt;BR /&gt;&lt;BR /&gt;That's of course less ugly with a help file:&lt;BR /&gt;&lt;BR /&gt;perl x.pl file1 file2&lt;BR /&gt;abc 4&lt;BR /&gt;def 5&lt;BR /&gt;ghi 6&lt;BR /&gt;------------- x.pl ----------&lt;BR /&gt;open F,shift;&lt;BR /&gt;@f1=&lt;F&gt;;&lt;BR /&gt;open F,shift;&lt;BR /&gt;@f2=&lt;F&gt;; &lt;BR /&gt;chomp @f1; &lt;BR /&gt;chomp @f2; &lt;BR /&gt;for $i (0..@f1){ &lt;BR /&gt;  system("echo  $f1[$i] $f2[$i]")&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/F&gt;&lt;/F&gt;&lt;/F&gt;&lt;/F&gt;</description>
      <pubDate>Thu, 01 Feb 2007 21:47:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026075#M97480</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-02-01T21:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026076#M97481</link>
      <description>Thanks to all for taking some time to explain.&lt;BR /&gt;&lt;BR /&gt;Sandman,&lt;BR /&gt;&lt;BR /&gt;  Would you please explain it. I liked this way.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Fri, 02 Feb 2007 08:58:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026076#M97481</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2007-02-02T08:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026077#M97482</link>
      <description>&amp;gt;Would you please explain it. I liked this way.&lt;BR /&gt;&lt;BR /&gt;Hmm, I've always thought that |&amp;amp; was useless junk.&lt;BR /&gt;&lt;BR /&gt;If you look at ksh(1), you see |&amp;amp; under Commands.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;&amp;amp;p and &amp;gt;&amp;amp;p under Input/Output.  And later it talks about redirecting them because you want another coprocess.&lt;BR /&gt;&lt;BR /&gt;Then under read, you can read -u#.&lt;BR /&gt;&lt;BR /&gt;So this does:&lt;BR /&gt;cat file1 |&amp;amp;&lt;BR /&gt;exec 3&amp;gt;&amp;amp;p; exec 4&amp;lt;&amp;amp;p&lt;BR /&gt;&lt;BR /&gt;Puts cat in the background and the exec changes the output to cat to 3 and input from cat to 4.  (3 seems pretty useless since cat is only reading from file1.)&lt;BR /&gt;exec with no executable just does file redirection/closing.&lt;BR /&gt;&lt;BR /&gt;cat file2 |&amp;amp;&lt;BR /&gt;exec 5&amp;gt;&amp;amp;p; exec 6&amp;lt;&amp;amp;p&lt;BR /&gt;&lt;BR /&gt;Again the same for 5 &amp;amp; 6.  Note 4 and 6 are the output FROM the two cats.&lt;BR /&gt;&lt;BR /&gt;read -u4 file1var1 &amp;amp;&amp;amp; read -u6 file2var1&lt;BR /&gt;&lt;BR /&gt;This reads one line from file 4 (from cat file1) and one line from file 6 (from cat file2).&lt;BR /&gt;&lt;BR /&gt;if [[ -z $file1var1 || -z $file2var1 ]]; then&lt;BR /&gt;&lt;BR /&gt;Checks for mismatched number of records and probably could print an error.</description>
      <pubDate>Sat, 03 Feb 2007 01:36:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026077#M97482</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-03T01:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026078#M97483</link>
      <description>IT,&lt;BR /&gt;&lt;BR /&gt;You can do simply &lt;BR /&gt;# paste 1 2 &amp;gt; result_file&lt;BR /&gt;&lt;BR /&gt;And the result file will be  result_file ,&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Sat, 03 Feb 2007 03:05:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026078#M97483</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2007-02-03T03:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: need a script to assign</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026079#M97484</link>
      <description>got it.</description>
      <pubDate>Wed, 07 Feb 2007 12:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-assign/m-p/5026079#M97484</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2007-02-07T12:42:21Z</dc:date>
    </item>
  </channel>
</rss>

