LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 04-23-2009, 06:28 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
echo $(i++) does not work


Hi,
echo $(i++) does not work on a shell does not increment the variable i.Where as echo $((i++)) works fine .So what's the difference between the two.

Thanks in advance.
 
Old 04-23-2009, 06:33 AM   #2
Libu
Member
 
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165

Rep: Reputation: 36
Pretty simple "(( ))" is integer expansion, whereas "( )" is just a way to create a new shell to run commands.
 
Old 04-23-2009, 06:38 AM   #3
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Thanks,
Do you know any material on the internet from which i can find more info on this.I am following "The Unix Programming Environment" book and i did not find the info over there.
 
Old 04-23-2009, 06:39 AM   #4
Libu
Member
 
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165

Rep: Reputation: 36
You will have to add spaces:
Quote:
echo $(( i++ ))
 
Old 04-23-2009, 06:41 AM   #5
Libu
Member
 
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165

Rep: Reputation: 36
This is one of the best that I have come across. I use it all the time:
http://tldp.org/LDP/abs/html/
 
Old 04-23-2009, 06:43 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Libu View Post
This is one of the best that I have come across. I use it all the time:
http://tldp.org/LDP/abs/html/
At the same site, start with Bash Guide for Beginners
 
Old 04-23-2009, 06:43 AM   #7
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Thanks for the link
Quote:
You will have to add spaces:
Even without spaces it works fine for me .
[sb@isro ~]$ echo $((i++))
7
 
  


Reply



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
echo on a new line does not work B-Boy Linux - Newbie 2 06-02-2008 09:54 AM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 08:25 AM
icmp echo reply wont work pali Linux - Networking 2 08-17-2005 12:34 PM
echo does not work in php code suchi_s Programming 3 10-21-2004 03:39 AM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:23 AM.

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
Open Source Consulting | Domain Registration