This is why I don't write in ksh much anymore, even IBM stuff has bash.
I'm not going to write this unless asked and there's no need to build
arrays, let the OS do it's work.
for each file in the source,
if it exists in destination,
delete the source file.
What's next move the remaining source files to the destination?
This isn't rocket science and is a simple loop based on the source doing
tests vs the destination, again let the OS do what it's made for. You
people are making this way too complicated.
If I wasn't making chili right now I'd write it for you.
{Joe Strummer and The Mescaleros}
> Send uwin-users mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.research.att.com/mailman/listinfo/uwin-users
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of uwin-users digest..."
>
>
> Today's Topics:
>
> 1. Re: Fwd: Re: More than one way to do it? (Danny Weldon)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 5 Oct 2014 09:36:12 +1000
> From: Danny Weldon <[email protected]>
> To: Douglas Houston <[email protected]>
> Cc: [email protected], David Nicol
> <[email protected]>
> Subject: Re: [uwin-users] Fwd: Re: More than one way to do it?
> Message-ID:
> <CAJDkJnFtR9dUWDkt2ON+Qu2tD2-ge3RQ=bi6juuanyn4dp1...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Since your list of filenames is probably unique, I would use an
> associative array instead:
>
> #Build an example array
> typeset -A array
> for ((c=0; c<=10000; c++)); do
> array[element$c.txt]=1
> 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
> if (( ${array[$delete_element]} )); then
> unset array[$delete_element]
> fi
> done
>
> # To iterate over the associative array
> for element in "${!array[@]}"; do
> print "$element"
> done
>
> # Or, if you want to convert it back to a standard array
> set -A array2 "${!array[@]}"
> print "${array2[@]}"
>
> On 3 October 2014 23:37, Douglas Houston <[email protected]>
> wrote:
>> Yes - or I could write it in assembly! ;-)
>>
>>
>> Quoting David Nicol <[email protected]> on Thu, 2 Oct 2014 13:37:49
>> -0500:
>>
>>> On Thu, Oct 2, 2014 at 3:56 AM, Douglas Houston
>>> <[email protected]
>>>>
>>>> wrote:
>>>
>>>
>>>>
>>>>
>>>>> 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?:
>>>>>
>>>>
>>>
>>> untested:
>>>
>>> perl -nle 'BEGIN{ @x{`cat secondlist.txt`} = () } exists $x{$_} or
>>> print'
>>> <
>>> firstlist.txt >filteredlist.txt
>>> mv filteredlist.txt firstlist.txt
>>>
>>>
>>>
>>> --
>>> Sometimes I imply things, or include important information in pictures.
>>> Without a request for clarification, I will assume I was clear, which
>>> can
>>> cause later problems when I wasn't. So please ask me to clarify
>>> anything
>>> that seems ambiguous. Doing so is not rude. Thank you.
>>>
>>
>>
>>
>> --
>> 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
>
>
>
> --
> Regards
>
> Danny
>
>
> ------------------------------
>
> _______________________________________________
> uwin-users mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/uwin-users
>
>
> End of uwin-users Digest, Vol 112, Issue 3
> ******************************************
>
_______________________________________________
uwin-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/uwin-users