Featured Worklog

Price Search



PC Apex Sponsor


PC Apex Sponsors



PC Apex RSS Feeds

RSS Feed for PC Apex Reviews & ArticlesRSS Feed for PC Apex PC Modding WorklogsRSS Feed for the PC Apex Daily DisturbanceRSS Feed for the latest PC Apex Site NewsRSS Feed for PC Apex Affiliate and Web NewsRSS Feed for PC Apex Deals and Steals

Go Back   Apex Community Forums // Other Forums // Designers Corner // Coding / Scripting / Programming

Coding / Scripting / Programming Discussions on all manner of coding and scripting.

Reply
 
LinkBack Thread Tools Display Modes
Old 22-March-05, 09:06 AM   #1 (permalink)
Apex Master Tech
SirDavisCarrots's Avatar
Default bash scripting: increment

do any of you know how to increment in bash?

or change type (string to interger)

trying to write a syncronization thing and sync's the passwd file on one server to the other

figured out awk and sed pretty cool commands
SirDavisCarrots is offline     Reply With Quote
Old 22-March-05, 09:40 AM   #2 (permalink)
'Da Doctor of Funk
FunkyFresh's Avatar
Default

It's been about 10 years since I've done bash scripting, but this should work. If someone has a better way, I'd love to know it since this seems pretty crude to me.

Code:
i=1;
i=`expr $i + 1`;
echo $i;
That code will print "2" when you run it. And by the way, those single quotes are the ones on the tilde key (~), not on the double-quote key ("). Then again, if you've already figured out sed and awk, you probably knew that...

By the way, it also works just the same if the first line is a string; the conversion should be automatic.
Code:
i="1";
FunkyFresh is offline     Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Register // Google cancels anti-eBay bash Gizmo The Register RSS 0 14-June-07 06:20 PM
The Register // Industry and academia line up to bash ID cards Gizmo The Register RSS 0 04-May-06 05:11 AM
The Register // Industry and academia line up to bash ID cards Gizmo The Register RSS 0 04-May-06 05:11 AM
project: bash in a box elfuego Project Worklogs 12 04-August-05 05:51 PM
Slashdot // From Bash To Z Shell Gizmo Slashdot RSS 0 14-April-05 03:05 AM


All times are GMT -5. The time now is 10:32 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright PCApex.com, GameApex.com, ForumApex.com 2001 - 2008
Advertisements

Page generated in 0.11787 seconds with 9 queries