Why "@z=$x+$y" doesn't work?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Why "@z=$x+$y" doesn't work?
# 1  
Old 01-18-2005
Why "@z=$x+$y" doesn't work?

253 lab2-36:~/try_direct/another> set x=1;set y=2;@z=$x+$y
@z=1+2: Command not found.
254 lab2-36:~/try_direct/another>
# 2  
Old 01-18-2005
What shell?

In ksh or bash (probably bourne), this will work:
Code:
X=1 ; Y=2 ; Z=`expr $X + $Y`

or in bash:
Code:
X=1 ; Y=2 ; let Z=$X+$Y

# 3  
Old 01-18-2005
TC shell , actually
# 4  
Old 01-18-2005
I have never used TC, but you might try the first example.

Read the man page on the shell. It should detail the use of shell built in's (mathematic functions are in most "modern" shells.)
# 5  
Old 01-18-2005
You've never used TC? Which shell is better, so far as you are concerned?
# 6  
Old 01-18-2005
The first one does not work:
254 lab2-36:~/try_direct/another> x=1;y=2;z='expr $x + $y'
x=1: Command not found.
y=2: Command not found.
z=expr $x + $y: Command not found.
255 lab2-36:~/try_direct/another>
# 7  
Old 01-18-2005
I changed a little bit about the first one, without any effect
255 lab2-36:~/try_direct/another> set x=1; set y=2; set z='expr $x+$y'
256 lab2-36:~/try_direct/another> echo $z
expr $x+$y
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

2. Shell Programming and Scripting

Why doesn't "grep -w" ALWAYS work?

Working with IP addresses is a pain... Here's my problem: I'm putting some interface information to a file: 3.185.201.2 | Tu1102 152.162.54.130 | Gi0/2.36 3.185.226.2 | Gi0/1 3.185.0.82 | Tu1 ... (12 Replies)
Discussion started by: turk22
12 Replies

3. AIX

AIX 5.3 on p275 - "|" key doesn't work (!)

More issues. The "|" key doesn't work at all, either in the text terminal or in mwm (which starts fine when I do "startx"). How am I supposed to troubleshoot without a "|" key? (2 Replies)
Discussion started by: smithfarm
2 Replies

4. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

5. UNIX for Dummies Questions & Answers

Help! "grep" doesn't work for me!

totally pis*ed off. I have a data set (xxx.txt), as follows: chr1 3821 rs127372 A/C 0.823 chr1 3822 rs127376 A/C/G 0.899 chr1 3722 rs612634 A/C 9.22 chr1 3262 rs7152 A/T 0.22 chr1 3711 rs737 A/C/G 0.2323 ....... I only want to get those lines... (6 Replies)
Discussion started by: kaixinsjtu
6 Replies

6. UNIX for Advanced & Expert Users

sometimes "ps -elf" command doesn't work

when i give "ps -elf" or "ps" system gets hung. if i press "^c" come out from it... pls help..what should i do to get it resolved. thanks CKanth (4 Replies)
Discussion started by: srikanthus2002
4 Replies

7. Linux

By angle-brackets/"pipe" button doesn't work?

How can I configure it? I have a swedish keyboard with swedish keyboard setting. Everything works perfectly (едц) except that button. What can be wrong? /Richard ++ NOTE: It seems like the computer notices the input but that the button isn't assigned to anything (the keyboard-cursor stops).... (1 Reply)
Discussion started by: riwa
1 Replies

8. Shell Programming and Scripting

my "case" doesn't work !

I'm using the case statement in the following script and it always takes the "*" default choice while it should be "3". I wonder why ??? dt_auj=`date +%d` NBLOG=`ls -al /users/notes01/LOG/t*|awk '{print $7}'|grep $dt_auj|wc -l` case $NBLOG in 1) cat ~/LOG/console-notes > $fic_tmp1 ;; 2)... (5 Replies)
Discussion started by: Nicol
5 Replies
Login or Register to Ask a Question