The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Increment userid in file dejavu88 Shell Programming and Scripting 2 05-26-2008 02:11 PM
Shell Script To increment Date*HElp*** niceboykunal123 Shell Programming and Scripting 1 04-22-2008 10:05 PM
Increment date in 'for' loop? SunnyK Shell Programming and Scripting 4 10-30-2007 03:12 AM
How to pattern match on digits and then increment? sdutto01 Shell Programming and Scripting 2 08-11-2005 11:46 AM
Increment counter in ksh steiner Shell Programming and Scripting 5 12-02-2003 05:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-13-2005
Registered User
 

Join Date: Jun 2005
Posts: 16
increment...

hi,

i want to increment a Variable but it doesnt work.

here my codé
Code:
COUNT=1
COUNT= 'expr $COUNT + 1'
i've tried it in the prompt but it print me:
expr: syntaxerror

What does I make wrong?
Reply With Quote
Forum Sponsor
  #2  
Old 07-13-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Use

Code:
count=1
count=$((count+1))
vino
Reply With Quote
  #3  
Old 07-13-2005
Registered User
 

Join Date: Jun 2005
Posts: 16
thank you

now it works
Reply With Quote
  #4  
Old 07-13-2005
Registered User
 

Join Date: Jun 2005
Location: Ireland
Posts: 61
be careful of spaces. You can't have spaces around =

COUNT=`expr $COUNT + 1`

vinos method uses the bash specific syntax
which will run faster as it doesn't need to
start a seperate expr process per increment.
Reply With Quote
  #5  
Old 07-13-2005
Registered User
 

Join Date: Jun 2005
Posts: 16
ok pixelbeat
thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0