![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Populating array raised an error | yoavbe | Shell Programming and Scripting | 1 | 12-05-2008 08:14 AM |
| Creating an array to hold posix thread ids: Only dynamic array works | kmehta | High Level Programming | 4 | 09-21-2008 09:24 PM |
| populating array using awk | yoavbe | Shell Programming and Scripting | 1 | 09-09-2008 05:30 PM |
| Awk help with populating variable | jmd2004 | Shell Programming and Scripting | 3 | 08-11-2008 04:25 PM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 09:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Populating an Array
Guys, 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 ==> Code:
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: Code:
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[i]="${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 ---------- Thanks a lot for your help and prompt reply
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|