The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-18-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

to read all emails into an array:

Code:
email=( $(cat file) )
Code:
TO=$email[1]
to convert the array to a list:

Code:
CC=$(for i in {2..${#email[@]}}; do printf "%s " ${email[$i]}; done)
Which iterates over the array starting at position 2 for the length of the array, the it prints the current array followed by a space but no line break. The result is passed to the variable CC. Now you have the TO in $TO and the CC in $CC.

HTH

Chris