LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-13-2004, 10:16 PM   #1
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Rep: Reputation: 30
bash script and the , operator


I'm trying to understand a portion of the article posted at the below link.
http://www.tldp.org/LDP/abs/html/special-chars.html
Code:
let "t2 = ((a = 9, 15 / 3))"  # Set "a" and calculate "t2".
this example that was take from the article shows the that the equation obviously assigns two variables, but how would it know what to do with the following, if the following is valid.
Code:
let "t2 = ((10*25, 15 / 3))"
it says that it only returns the last operation, so would 10*25 be calculated and the product lost? other than the top most example is there any other real reason for this comma operator?
 
Old 08-14-2004, 12:33 AM   #2
idaho
Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438

Rep: Reputation: 30
This is what I saw when I tried your code:
idaho@pikachu:~$ let "t2 = ((10*25, 15 / 3))";echo $t2
5

As you surmised, the 10*25 was calculated and discarded.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash equivalent to C increment operator andrewb758 Linux - General 5 02-21-2009 12:25 PM
Bash scripting and && operator Dark_Helmet Programming 16 09-18-2005 09:57 PM
shell script provides an error that a binary operator is required max_rsr Linux - General 1 03-12-2005 08:26 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
Script file problem (or operator problem) HELP! lostone Programming 2 05-23-2001 02:30 PM


All times are GMT -5. The time now is 06:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration