Sponsored Content
Top Forums Shell Programming and Scripting Why won't my Ksh do math with (( ))? Post 302361211 by troym72 on Monday 12th of October 2009 03:11:07 PM
Old 10-12-2009
Why won't my Ksh do math with (( ))?

Hello,

I'm usring Ksh on AIX 5.3. For some reason my K-Shell gives me an error when I try to use the math operators (( )).

Can anyone tell me what's going on and how to fix it?

Thanks so much!

My K-Shell:
Code:
/>ls -al /usr/bin/ksh
-r-xr-xr-x   5 bin      bin          237420 Apr 10 2007  /usr/bin/ksh

Commands:
Code:
 
/>myvar=$ (( 1 + 1 ))
ksh: syntax error: `(' unexpected
 
/>myvar=`expr 1 + 1`
/>echo $myvar
2
 
/>let myvar=$ (( 1 + 1 ))
ksh: syntax error: `(' unexpected

 

10 More Discussions You Might Find Interesting

1. Programming

something about <math.h>

Hi, I got an easy problem for you but really difficult for me 'cause I am pretty new to this field I got header file <math.h> included in my .c file , then I write the code as below: k = sqrt(i); /* both variables k and i are int */ then I cc temp.c it says like this undefined... (4 Replies)
Discussion started by: blf0
4 Replies

2. UNIX for Dummies Questions & Answers

Ksh Why Won't IF Statement work?

I'm trying to figure out why this if statement won't work: if || $zipcount != 6 ]] then echo ${myline} echo "ZIPCODE WARNING! ${zipcode} ${zipcount}" fi if ]] then echo ${myline} echo "STATE WARNING!... (3 Replies)
Discussion started by: developncode
3 Replies

3. AIX

won't mount /usr...won't boot fully

Hello: NOOB here. I attempted to use smit mkcd. Failed on first attempt, not enough space. 2nd attempt tried to place iso on /usr, not enough space there. Cleanup ran for about 5 minutes after aborting. Now AIX won't boot. LCD display on 7029-6E3 says: 0517 MOUNT /USR. Attempted to boot from CD... (11 Replies)
Discussion started by: bbird
11 Replies

4. Shell Programming and Scripting

math help

$ x=1 $ y=1.5 $ z=$((x*y)) bash: 1.5: syntax error: invalid arithmetic operator (error token is ".5") What's wrong? (2 Replies)
Discussion started by: rockbike
2 Replies

5. Shell Programming and Scripting

created a .alias, but they won't take (ksh)

I login with a common username, and have no access to the different login scripts for my personalizations. So for a while, I would hobble on over to a directory I made for myself, and then bring in my alias file where I would fix my backspace, create a few aliases, etc.: $ ./.alias $ Now... (4 Replies)
Discussion started by: hindesite
4 Replies

6. Shell Programming and Scripting

ksh date math

I have a requirement to remove all files from a directory execpt those > (now -N hrs). Once I can figure out how to calculate (now -N hrs) I was thinking of creating a temporary file with that time (now-N hrs) than using the find and -newer option. Does anybody have any KSH code (needs to... (3 Replies)
Discussion started by: BeefStu
3 Replies

7. Shell Programming and Scripting

Math action in ksh

Hello, I want to do div action in ksh and get the full result(with leftover). i.e. 4/3=1.33 and not 4/3=1 (4 Replies)
Discussion started by: LiorAmitai
4 Replies

8. Shell Programming and Scripting

ksh field math

Hi, I have a text like with many rows of data like: 7a,0,1182 7a,1,1040 7b,0,483 7b,1,242 7c,0,224 7c,1,877 I need to be able to take the value of the first field (i.e. 7a) and if there are multiples, add the value of the third field, (1182 + 1040) and insert the output of all of this in... (2 Replies)
Discussion started by: scriptr2be
2 Replies

9. UNIX for Dummies Questions & Answers

Math

i have file (my_file.txt) that looks like this: 000000000000010000 000000000000010000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 all said and one, it should look... (11 Replies)
Discussion started by: lawsongeek
11 Replies

10. UNIX for Beginners Questions & Answers

Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK... (3 Replies)
Discussion started by: yelirt5
3 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 09:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy