Incremental logic


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Incremental logic
# 1  
Old 01-21-2017
Incremental logic

Hi Guys,
am trying to write logic to do incremental value using linux
Example:
Code:
a=00.00.00.01

My b should be like this

Code:
b=00.00.00.02

and when it reaches 99 my b should look like this
Code:
b=00.00.01.99


Appreciate your help guys
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.

Last edited by RudiC; 01-22-2017 at 07:15 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 01-22-2017
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework Questions forum under special homework rules.

If this is not a homework assignment, please explain the company you work for and the nature of the problem you are working on. And, please show us what you have tried to solve this problem on your own (in CODE tags).

If you did post homework in the main forums, please review the guidelines for posting homework and repost.
# 3  
Old 01-22-2017
Hi , Am trying bump the SNAPSHOT version in pom.xml , My company is APERVI
This is what i tried
Code:
 a=00.00.00.01
 b=`echo $a | cut -d"." -f1,2,3`"."`expr \`echo $a | cut -d"." -f4\` + 1`
echo $b
00.00.00.2


Last edited by Don Cragun; 01-22-2017 at 12:51 AM.. Reason: Fix CODE tags.
# 4  
Old 01-22-2017
Here is a tutorial showing how to use CODE and ICODE tags:
# 5  
Old 01-22-2017
What operating system and shell are you using?

Have you considered using awk?

Do you really want to go from 00.00.00.99 to 00.00.01.99 or do you really want to go to 00.00.01.00? That is, is the intent to always have each element of the version number be a two-digit number where low order elements count from 00 through 99 and then resets to 00 when incrementing the next higher element? Or, does an element of the version number lock at 99 when the next higher order element increments from 00 through 99 as shown in post #1?
# 6  
Old 01-22-2017
No I haven't tried awk , I think I would like to go 00.00.01.00 once it reached 00.00.00.99

Last edited by rbatte1; 01-23-2017 at 06:18 AM.. Reason: Added ICODE tags and corrected grammar
# 7  
Old 01-22-2017
I repeat: "What operating system and shell are you using?"

And, where is this version number stored? Are you reading it from a file, or is it stored in a variable in your shell script?
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

incremental by 1

let says, i have this number as 000002080, i want to add 1 to make it 000002081, and then i want to add 1 to 000002082, add 1 to 000002083, 84. i=000002080 TOT=$(echo "scale=9; $i + 1" | bc) echo $TOT it shows 2081, i want to retain 000002081, 000002082, 000002082, 000002084. (2 Replies)
Discussion started by: tjmannonline
2 Replies
Login or Register to Ask a Question