read 2 file and loop at same time ksh script

September 24, 2010 at 01:28:21
Specs: Windows 2000
Hi all,
I write a script in ksh like this 1:
#!/bin/ksh
folder=" /ebsxe/ebs25/users/mmlim/assignment01/dir01 "
cd $folder

while read file
do

set $(echo ${file})

cd $1

var=`ls -1 | wc -l`

if [[ $var -lt $2 || $var -eq $2 ]]; then
echo " $3"
else
echo " $3 "
fi

done <config.txt

the output is :
group1
group2

Then from that script i want read my another file :
file2:
group1 email1
group2 email2

After it read and loop it the output should be this :
email1
email2

How i going to done it?


See More: read 2 file and loop at same time ksh script

Report •

#1
September 24, 2010 at 08:47:20
One way is to use the shell to parse the line. Since your file2 has 2 columns:

# Untested
while read groupvar emailvar
do
   echo "$emailvar"
done < file2

I can comment on your other script if you want. For example, instead of testing for less than or equal this way:

if [[ $var -lt $2 || $var -eq $2 ]]; then

combine the two:

if [[ $var -le $2 ]]; then

Let me know if you want me to comment further on your original script.


Report •
Related Solutions


Ask Question