LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2006, 12:02 PM   #1
sporty
LQ Newbie
 
Registered: Oct 2005
Location: Austin, Tx
Posts: 18

Rep: Reputation: 0
expr question


When I try the following code in a bash script

$xa=`expr ($a - $b) % 3`

I get this error:

./mod: command substitution: line 13: `expr ($a - $b ) % 3'

Can anyone help me understand what this error means?

This error also occurs if I hard code the values such as `expr (10 - 3) % 3`
 
Old 03-22-2006, 05:02 PM   #2
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
sporty,

Not to farmiliar with the expr command, but I have read through the man pages.

What if you try the command like this;

Code:
expr \( 10 - 3 \) % 3
Does this produce the output you require?

-Kristijan
 
Old 03-22-2006, 05:15 PM   #3
sporty
LQ Newbie
 
Registered: Oct 2005
Location: Austin, Tx
Posts: 18

Original Poster
Rep: Reputation: 0
[QUOTE=Kristijan]sporty,

Not to farmiliar with the expr command, but I have read through the man pages.

What if you try the command like this;

Code:
expr \( 10 - 3 \) % 3
Does this produce the output you require?

Yeah that worked, I had tried that earlier but I guess I must have had a typo.
Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expr in Shell mystical_sun2000 Linux - Newbie 1 02-08-2006 07:59 AM
About how to use expr naihe2010 Programming 2 10-31-2005 07:28 AM
expr syntax error baosheng Programming 4 06-09-2005 04:32 PM
simple expr izza_azhar Programming 3 01-17-2005 08:38 PM
EXPR in shell pragti Programming 3 07-21-2004 04:54 PM


All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration