Ksh: how compare content of a file with an other array

Hi,
I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created:

example content file:

hello;AAAA;2014-08-17
hello;BBBB;2014-08-17
hello;CCCC;2014-08-17

I would need to compare the content in of the second column of this file with an array
Example array:

array[1]=AAAA
array[2]=BBBB
array[3]=CCCC
array[4]=DDDD

If there is some missing values in the file I would need to insert it in the file after the comparison:

in this example would be:

hello;AAAA;2014-08-17
hello;BBBB;2014-08-17
hello;CCCC;2014-08-17
hello;DDDD;2014-08-17

Could you please help me and show me how can I (in ksh)
1) create an array from a column
2) compare this array with an other array and show the differences

Thx a lot!

What have you actually tried so far?

What type of array is this where the first element is indexed at [1] ?

I was meaning like this

array[0]="AAAA"
array[1]="BBBB"
array[2]="CCCC"
array[3]="DDDD"

Yes I've tried but I did not found yet a solution.. any help would be great

Welcome jmartin,
I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.