Array Issue In Bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Array Issue In Bash
# 1  
Old 08-07-2014
Array Issue In Bash

Hi,
I have the following code which is giving error mentioned below. Please can you support on this. Also suggest how can we access all the items against single vasservicename in circlename array,i.e, vasservicename say MTSTV will be available to all circles which are mentioned in the array circlename


Code:
cdrfilename ()
{
        local out=SS_$1_CDR_$2.txt
        echo $out
}
declare -a circlename=(KRL GUJ UPW CHN DEL ROWB KOL RAJ KTK)
declare -a vasservicename=(MTSTV CRBT )
runtime=`date +%Y%m%d%H%M%S`

for (( counter=0; counter <${#vasservicename[@]};counter++ ))
do
      for (( count=0; count <${#circlename[@]};count++ ))
      do
                cdrfile[$counter][$count]=$(cdrfilename "${circlename[count]}_${vasservicename[counter]}"  $runtime)

                done
        done

Error:
Code:
CDRFILE[7][7]=SS_RAJ_MMSC_CDR_20140807125243.txt: command not found
./vastest.sh: line 1199: CDRFILE[7][8]=SS_KTK_MMSC_CDR_20140807125243.txt: command not found

# 2  
Old 08-07-2014
Quote:
Originally Posted by siramitsharma
Error:
Code:
CDRFILE[7][7]=SS_RAJ_MMSC_CDR_20140807125243.txt: command not found
./vastest.sh: line 1199: CDRFILE[7][8]=SS_KTK_MMSC_CDR_20140807125243.txt: command not found

From the man page of bash:

Quote:
6.7 Arrays

Bash provides one-dimensional indexed and associative array variables.
What you try to do is to use a two-dimensional array, which simply doesn't exist in bash.

I hope this helps.

bakunin
# 3  
Old 08-07-2014
man bash:
Quote:
Arrays
Bash provides one-dimensional indexed and associative array variables.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Array connectin to another Array

Hello, i have a script that i need account_number to match a name. for exsample : ACCOUNT_ID=(IatHG8DC7mZbdymSoOr11w KbnlG2j-KRQ0-1_Xk356s8) and i run a loop curl requst with this the issue is that i want to know on which account were talking about so bash will know this : ... (4 Replies)
Discussion started by: batchenr
4 Replies

2. Shell Programming and Scripting

awk array next issue

Hi, Here's an example of what I my issue, a file list.txt, which looks like: a b c d e I have been trying to use the following code to simply print the list using awk and next: awk 'FNR==NR{a=$1;next}{print a}' list.txt this give no output, even though I would expect it to type out... (5 Replies)
Discussion started by: hexy
5 Replies

3. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

4. UNIX for Dummies Questions & Answers

Help with bash array

Hi, I would like to remove audio tracks from several video clips contained in a single directory using the command files=(*.mpg); ffmpeg -i "${files}" -vcodec copy -an na/output.mpg I want each processed file outputted to the sub-directory na retaining the original file name, how do I do that?... (4 Replies)
Discussion started by: jeppe83
4 Replies

5. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

6. Shell Programming and Scripting

Issue with array in shell

So i have used arrays for a while now but I just notice in one of my arrays when using an array with 9+ items in it that after running a for loop on the array it was replacing the first array with what ever was last and I cant figure out why. Here is my code. #!/bin/bash vm=( 0 1 2 3 4 5 6... (3 Replies)
Discussion started by: snptuning
3 Replies

7. Shell Programming and Scripting

Scripting array issue

Hi guys, I'm a scripting noob in need of some help :) I am creating a script that checks the filesystems and will alert based upon if the percent full is greater than the threshold set. The problem that I am having is that when I set the 'filesystem' variable, all of the output is treated as... (12 Replies)
Discussion started by: tank126
12 Replies

8. Shell Programming and Scripting

bash Script: Issue with iterating Directory and store into array

Hi all, I am working on a backup based script, in which it enters to a directory and check the sub-directories and copy the names into an array. cd $CPFs k=0 for i in * do if then ARRs="$i" k=$(($k+1)) #echo "$i" ... (19 Replies)
Discussion started by: canishk
19 Replies

9. Solaris

V880 and T3 array issue

We're trying to install a third T3 array onto our V880. The other two T3's are connected to a qlogic fibre card. We can see this connection fine when we do a luxadm probe -p command. The full device paths are shown etc. ie: the first T3's logical name is c2t1d0 and the second one is c3t1d0. ... (3 Replies)
Discussion started by: mjl927
3 Replies

10. Shell Programming and Scripting

Dynamic Array Issue

Could one of you, please, provide some input regarding my problem below and it is as follows: I have 2 files that I need to make sure are identical before processing: First, I sort both files Second, I do a diff file1 file2 > File 3 This provides me with the difference. Now, I need to... (6 Replies)
Discussion started by: ddedic
6 Replies
Login or Register to Ask a Question