Syntax Issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Syntax Issue
# 1  
Old 10-05-2012
Data Syntax Issue

Hello all. Need a bit of help...

I have :

Code:
previous_tmp0=`cat tmp0.txt`
previous_tmp1=`cat tmp1.txt`
previous_tmp2=`cat tmp2.txt`
previous_tmp3=`cat tmp3.txt`
previous_tmp4=`cat tmp4.txt`
previous_tmp5=`cat tmp5.txt`
previous_tmp6=`cat tmp6.txt`
previous_tmp7=`cat tmp7.txt`

Now I want to use the following :

Code:
for i in 0 1 2 3 4 5
do
echo "$previous_tmp$i"
if [ ${ARRAY_MOUNT_POINT_CAPACITY[$i]} -eq $previous_tmp$i]
then
    echo "File Size Same of ${ARRAY_MOUNT_POINT_NAME[$i]}"
elif [ ${ARRAY_MOUNT_POINT_CAPACITY[$i]} -gt $previous_tmp$i ]
then
   echo "Mount Point Increase"
else
   echo "Mount Point Decrease"
fi
done

In the line : if [ ${ARRAY_MOUNT_POINT_CAPACITY[$i]} -eq $previous_tmp$i]

, how do I write the statement $previous_tmp$i so that if cals the proper variables ?
# 2  
Old 10-05-2012
For testing script, need to define arrays: ARRAY_MOUNT_POINT_CAPACITY, ARRAY_MOUNT_POINT_NAME

in line 4: include a space before closing square bracket.

define value for $previous_tmp$i as new variable.
# 3  
Old 10-05-2012
Why dont you say you have an error and display the message you got?
# 4  
Old 10-05-2012
I have already defined them . The issue that I am facing right now is how to call the variable within another variable .

$previous_tmp$i

$i is one variables that is being called within $previous_tmp$i.
when the value of i =0,
it should be
$previous_tmp1
which then calls the value stored in $previous_tmp1 that is 23 that i got using

previous_tmp1=`cat tmp1.txt`....
# 5  
Old 10-05-2012
Without that missing space, you wont be going far...
If i is a vatirable "within a variable" it can only be the same.. if i=0 it cannot be i=1 unless you affect a new value... or its another variable... so create another one...
# 6  
Old 10-05-2012
example of defining var:
Code:
previous1=aaa
x=1
var=`set | grep "^previous$x="`
var=${var#*=}
echo $var
aaa

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dpkg Syntax Issue . . .

Greetings! I'm trying to get dpkg to just completely extract a multi-part *.deb archive set into a single folder called "output". Simple? Hmmmm.... dpkg --noforce --unpack *.deb /output/Console after ops: However, "--noforce" is taken directly from the helpfile Options listing as furnished... (8 Replies)
Discussion started by: LinQ
8 Replies

2. Shell Programming and Scripting

TCSH IF syntax issue

Hi All, I'm trying to write a simple if statement in TCSH and I honestly can't figure out what I'm doing wrong. I've played around with all sorts of permutations of syntax. if ($DESKTOP_SESSION == "kde") then replace "forceFontDPI=0" "forceFontDPI=96" --... (0 Replies)
Discussion started by: VerticalMule
0 Replies

3. UNIX for Advanced & Expert Users

Syntax issue in curl for getting a file from http site

Hi All I am using curl in my client environment. We need to pull a file from the libraries site. All the files are having perticular URL which can be used to get the files. Only issue is, when we fire that command , it will take to authentication page 1st. once authentication is succed, it will... (1 Reply)
Discussion started by: prabirkumardhar
1 Replies

4. Shell Programming and Scripting

syntax issue mysql in bash script

I'm running mysql in a bash script mysql <<EOF query EOF one query is like this: UPDATE $dbname.$prefix"config" SET value = $var WHERE "$prefix"config.name = 'table colname'; with variable but it's giving an error i'm not sure what to put for "$prefix"config.name the table... (3 Replies)
Discussion started by: vanessafan99
3 Replies

5. Shell Programming and Scripting

Syntax error, not understanding the issue?

Close please. Refer to following thread: Sub Menu issues (2 Replies)
Discussion started by: Banned
2 Replies

6. Shell Programming and Scripting

expr/bc syntax issue

Hi, I am facing issues in my shell script while trying to add two variables. Look at the snippet below for details: # Initially variable SAMPLE1 and SAMPLE2 are set from different sources. Have trucated decimal to avoid numeric errors in expr SAMPLE1=`/usr/bin/top -n 1 | head -3 | tail -1... (3 Replies)
Discussion started by: animesh303
3 Replies

7. Shell Programming and Scripting

Help with a possiable syntax issue in my script

Hello I have tried to my best ability to work around this script tht will reference my m-names.txt which contains the format of: 168.16.0.0/16 169.56.0.0/16 132.2.0.0/16 122.5.0.0/16 Then I call a cli named getzoneprof that will set the $subnet from each of the lines in the... (6 Replies)
Discussion started by: richsark
6 Replies

8. Shell Programming and Scripting

Help understanding syntax error Issue

Hi i as you may already know i am creating a menu driven program. I have chosen to take the approach of implementing each interface individually, after adding another interface and attempting to run the program i am faced with the following error: ./Assigntest: line 32: syntax error near... (6 Replies)
Discussion started by: warlock129
6 Replies

9. Shell Programming and Scripting

syntax issue in ksh file

Hi all, I am struck with syntax for long time, Need to purge some lines from given file Not able to use value of $x Example of ksh script... Facing some syntax issue. Have Tried ‘with single , double ,backtick “” ` and \ escape character , doesn't seem to work. <line 1> echo $x #... (2 Replies)
Discussion started by: manav666
2 Replies

10. Programming

Calculate scores and probability -- Syntax issue

Hi, I am totally new to C programming on Sun Solaris environment. I am an active member on the UNIX forum and a good shell programmer. I am trying to achieve some calculations in C programming. I have the pseudo code written down but don't know the syntax. I am reading a couple of books on C... (4 Replies)
Discussion started by: madhunk
4 Replies
Login or Register to Ask a Question