Extract from txt file

I have data as follow in the txt file.

I want to skip line starting with '#' sign.

#command program
abc defmt
exp refmt
... ...

I want to store abc exp .... in a array.
I want to store defmt refmt in a array

I need command to read each line in the file.
I need command to parse data in each line.
I need command to skip line starting with #.

Any basic clue will be sufficient I will build on top of it.

Thanks a lot in a advance.

Your request has the 'look and feel' of homework? To merely read data and store to an array does not serve any purpose. Please explain what you are trying to do.

I want to build menu item from the text file and excute command from the variable array.

> cat file25
# disregard this data
aaa choice_a
bbb choice_b
ccc choice_C
ddd choice_d
# forget this line
eee choice_e

> cat play25.sh
awk '
  { 
    if ($1!="#")
      { 
#      print $0 
      opt[$1]=$1
      choice[$1]=$2
      }
  }
  END {
    for (i in opt)
    print "Option="opt" and value ="choice

  }
' file25

> play25.sh
Option=aaa and value =choice_a
Option=ccc and value =choice_C
Option=eee and value =choice_e
Option=bbb and value =choice_b
Option=ddd and value =choice_d

Thanks a lot for the script.

I tried this. If I want opt and choice array available to me outside awk then what I need to do.

Basically I want to use this array in the script following awk command.

Any tip ...

$
$ cat data.txt
# a comment here
aaa menu_item_1
bbb menu_item_2
ccc menu_item_3
$
$ cat testscr.sh
#!/usr/bin/bash
opt=(`sed -n '/^[^#]/p' data.txt | cut -d" " -f1`)
menuitem=(`sed -n '/^[^#]/p' data.txt | cut -d" " -f2`)
for i in ${opt[@]}; do
  echo "Option = $i"
done
for i in ${menuitem[@]}; do
  echo "Menuitem = $i"
done
$
$ . testscr.sh
Option = aaa
Option = bbb
Option = ccc
Menuitem = menu_item_1
Menuitem = menu_item_2
Menuitem = menu_item_3
$
$

tyler_durden

while(<DATA>){
	next if /^#/;
	my @tmp=split(/\s+/,$_);
	push @arr1, $tmp[0];
	push @arr2, $tmp[1];
}
print join "|", @arr1;
print "\n";
print join "|", @arr2;
__DATA__
#command program
abc defmt 
exp refmt
#another command line
bbb defmt
ccc defmt