It is currently Tue, 30 Nov 2021 16:54:13 GMT



 
Author Message
 Urgent for KSH Gurus : matching source and target lists to create new one(ksh)
I am collecting process ids only with grepping into $new and process
all process ids and then save original list of process ids into $old,
this second time I have two lists $new (which has lastest process ids,
some may be new ones added) and $old (which holds process ids that I
have already processed)  I am running
in look like this every 5 seconds 'while process.... true  do sleep 5
done '

Now my question is, how I can get the latest list of process ids as
following in korn shell i.e.

$latest=($new-$old) # I don't want to process the old ids again
therefore
                    # $latest will have only process ids that need to
be
                    # processed.

Thanks very much in advance for your help.



 Sat, 06 Mar 2004 06:03:28 GMT   
 Urgent for KSH Gurus : matching source and target lists to create new one(ksh)
On 17 Sep 2001 15:03:28 -0700, sethi_san...@hotmail.com (b10) wrote:

Hi,

You could use a sort of hash array by setting variables 'tab_[PID]'
with the values of the $old list then loop through values in the
$new list and see if their entries are present, when they aren't
the items are added to $latest. This will work in any bourne
shell and should be pretty fast;

#!/bin/sh
latest=
for i in $old
do
  eval tab_$i=1
done
for i in $new
do
  eval v=\$tab_$i
  [ -z "$v" ] && latest="$latest $i"
done
for i in $old
do
  eval tab_$i=
done

byefrom,

--
: ${L} # http://lf.8k.com:80



 Sat, 06 Mar 2004 07:48:48 GMT   
 Urgent for KSH Gurus : matching source and target lists to create new one(ksh)
You might try something like this, it will give you PIDs that are unique
to either list, i.e. it will work only if $new is a superset of
$old.
      echo "$new$old" | sort | uniq -u

-- Context deleted.
-- more deletia

--
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
     Cal Dunigan      cdi           There is something fundamentally
       Consulting     Unix          wrong with a world in which Ken
       Modeling       Perl          Thompson lives in obscurity and
       Training       VHDL          Bill Gates is a famous billionaire.
//////////////////////////////////////////////////////////////////////



 Sun, 07 Mar 2004 01:56:51 GMT   
 
   [ 3 post ] 

Similar Threads

1. Need KSH function to list numbers ! in list

2. ksh: Copying files one by one

3. Pattern matching in ksh

4. How can I pattern-match in ksh?

5. ksh script- array matching -please help

6. Matching a value in an array using ksh

7. ksh and pattern matching

8. ksh pattern matching when pattern is in a variable

9. ksh discrepancy on pattern matching

10. KSH Pattern Match Deletions


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software