Hi all,
I have two lists of filenames, and I need to delete every entry from
the first list that appears in the second list. The way I'm doing it
right now seems awfully slow ... can anyone tell me if there is a way
to do it in ksh that runs faster than this does?:
#Build an example array
for ((c=0; c<=10000; c++)); do
array+=(element$c.txt)
done
#Build a second array containing all of the elements to be deleted
from the first array
for ((n=0; n<=5000; n++)); do
delete_elements+=(element$n.txt)
done
#For each element to be deleted, search the first array for the
element string and delete it whenever found
for delete_element in ${delete_elements[*]}; do
array=(${array[*]//${delete_element}})
done
This code takes about a minute to execute on my system (Intel Core 2
Duo [email protected]) at 100% CPU utilisation - seems like a lot of
churning considering the size of the array?
Thanks in advance for any advice.
cheers,
Doug
_____________________________________________________
Dr. Douglas R. Houston
Lecturer
Room 3.23
Institute of Structural and Molecular Biology
Michael Swann Building
King's Buildings
University of Edinburgh
Edinburgh, EH9 3JR, UK
Tel. 0131 650 7358
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
uwin-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/uwin-users