Note that there are some explanatory texts on larger screens.

plurals
  1. POEasier way to compare variables
    primarykey
    data
    text
    <p>I need to compare a set of variables from file 'tmpcsv2' with variables in 'uniq_id', I'm detailing the files below.</p> <p>tmpcsv2 -> This file gets updated by another script 'script1' and each run of 'script1' updates (not append) new variables in 'tmpcsv2'. The no. of variables might be 1 and can go till 200.</p> <pre><code>eg: 2042344352 2470697747 2635527510 3667769962 </code></pre> <p>uniq-id -> This is a fixed set of variables (about 100K in no.)</p> <pre><code>(Business Name,Job ID,Job Size) biz,1000036446,225210640 biz,100006309,6710840 biz,1000069211,2084019000 biz,1000118720,34194040 biz,1000150241,212322636 </code></pre> <p>I'm using 'for' loops + 'if' to compare them as shown below, is there a easier or faster (less impact) way of doing this ? When I run this it take a very long time to output results. The print commands are just for testing and will be removed later!</p> <pre><code>****Part of a bigger script**** amt=0 mjc=0 for jbid in `cat tmpcsv2` #Pick ID for match &amp; calculation do printf "Checking ID $jbid\n" &gt;&gt; Acsv3.tmp for bsid in `cat uniq_id` #Matching jobs &amp; size calulation do ckid=`echo $bsid | cut -d "," -f2` #ckid is the ID to check jbsiz=`echo $bsid | cut -d "," -f3` #size of the ID if [ $jbid == $ckid ] then printf "Matched at $ckid\n" #Print on Match found printf "Valid -&gt; $jbid\n" &gt;&gt; Bcsv3.tmp ((mjc++)) #Increment Matched Job Count amt=$((amt+jbsiz)) #Add size of matched jobs break else printf "No Match at $cksid\n" #No matches fi done printf "Check for ID $jbid done\n" &gt;&gt; Acsv3.tmp printf "Matched $mjc jobs with combined size of $amt\n" &gt;&gt; Acsv3.tmp done ****End of Comparision**** </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload