Assigning zero to element of ksh array.

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Assigning zero to element of ksh array.
# 1  
Old 04-01-2012
Assigning zero to element of ksh array.

Code:
set -A matched                                          #find referenced files.
        for i in ${file_names_html[*]}
        do
                counter_j=0
                for j in ${file_names_minus_index[*]}
                do
                        match=`cat $i | grep "<a.*href=\"$j\".*>.*<\/a>" | wc -l`
                        if [[ $match -ne 0 ]]
                        then
                                ${file_names_minus_index[$counter_j]}=0
                        fi
                        let counter_j=$counter_j+1
                done
        done

I am getting the below error message. I am not sure why. Plz help.
Code:
2_a: line 52: /Users/2_dir/public_html/a=0: not found

I took away the { } from the array and it seems to work now. Why did that matter?

Last edited by Scrutinizer; 04-02-2012 at 02:08 AM.. Reason: code tags
# 2  
Old 04-02-2012
You must have also taken away the $-sign, no?
Code:
file_names_minus_index[$counter_j]=0

The syntax you used earlier is used for referencing an array element, not for setting one.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assigning * as value in a ksh array

I want to extract each and single character from a password string and put it in an array. I tried this : set -A password "echo $passwd | awk '{for (i=1; i<=length($1); i++) printf "%s ",substr($1,i,1)}'` It's working as long that the password string doesn't contains any * I tried a few... (5 Replies)
Discussion started by: ce9888
5 Replies

2. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

3. Shell Programming and Scripting

File names as array element in ksh

Hi, I have an ksh array(ARR). the elements to the array are file names. i need to go to each file in the array and manipulate the records. for name in ${files}; do ---this loop is for all the file names in the array for i in $(wc -l < $name); do --this loop is for all the records in... (20 Replies)
Discussion started by: usrrenny
20 Replies

4. Shell Programming and Scripting

Assigning Column Values to ARRAY in ksh

Hi , i have file which is having two fields in it (#delimited) ABC#FILE_01.DAT DEF#FILE_02.DAT i want to write first field values to one array example A_01 and second field values to B_02 array please let me know how to do this ,my final requirement i have send out a mail for each record... (2 Replies)
Discussion started by: kkabc789
2 Replies

5. Shell Programming and Scripting

Not able to call an element from an array in ksh

Hi, I have: # Initialize variables #!/usr/bin/ksh FILENM=$1 INDEX=0 # read filename echo "You are working with the Config file: $FILENM" while read line do echo $line data=$line ((INDEX=INDEX+1)) done <"$FILENM" (3 Replies)
Discussion started by: Marc G
3 Replies

6. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

7. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

8. Shell Programming and Scripting

Problem to initialize ksh array when first element includes hyphen

Hi I'm trying to create an array with variable including hyphen but ksh refuses the first element set -A allArgs set +A allArgs ${allArgs} -all set +A allArgs ${allArgs} -date set +A allArgs ${allArgs} test ./test.ksh: -all: bad option(s) It happens only when first element is like... (4 Replies)
Discussion started by: gdan2000
4 Replies

9. Shell Programming and Scripting

Adding array element in KSH

All, I would like to add the first 10 elements of an array. Here is how I am doing it now (only included first few add ops): #!/usr/bin/ksh ###Grab the array values out of a file### TOTAL=`awk '/time/' /tmp/file.out | awk '{print $4}'` set -A times $TOTAL SUM=$((${times} + times... (3 Replies)
Discussion started by: Shoeless_Mike
3 Replies

10. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies
Login or Register to Ask a Question