I need to iterate populate an array while going over files in directory. Can someone please tell me syntax I tried this but it isn't working ==>
for F in `ls -p "${directory1}" | grep -v "\/"`
do
cd "${directory2}"
cmp "${directory2}"/"${F}" "${directory1}"/"${F}" >/dev/null;REPLY=$?
if [ ${REPLY} -eq 0 ]
then
file_arr_idd=($F)
echo "$file_arr_idd[0]"
else
file_arr_diff=($F)
fi
done
Hey kshji!! I just completed my Program I used the follwoing method to populated and run my array:
set -A file_arr_diff
set -A file_arr_idd
i=0
j=0
for F in `ls -p "${directory1}" | grep -v "\/"`
do
cd "${directory2}"
F2=$(find "${directory2}" -name "$F")
if [ "$F2" = "" ]
then
print "WARNING: Could not locate file : $F in $directory2"
fi
cmp "${directory2}"/"${F}" "${directory1}"/"${F}" >/dev/null;REPLY=$?
if [ ${REPLY} -eq 0 ]
then
file_arr_idd="${F}"
((i+=1))
else
file_arr_diff[j]="${F}"
((j+=1))
fi
done
for FILES in ${file_arr_idd[*]}
do
echo "$FILES are identical"
done
echo "********************************************************************************************"
for FILES in ${file_arr_diff[*]}
do
echo "$FILES are different"
done
echo "************************************End of Program*******************************************"
---------- Post updated at 03:13 PM ---------- Previous update was at 03:13 PM ----------