Incremental logic


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Incremental logic
# 8  
Old 01-22-2017
am reading it from pom.xml, lets say original one is [project-SNAPSHOT-00.00.00.01]
And i should change that to [project-SNAPSHOT-00.00.00.02] push back git

Last edited by RudiC; 01-22-2017 at 07:17 AM..
# 9  
Old 01-22-2017
Quote:
Originally Posted by Don Cragun
I repeat: "What operating system and shell are you using?"
.
.
.
Assuming bash being your shell:
Code:
b=$(printf "%08d" $(( 10#${b//./} + 1 )) | fold -w2 | paste -sd.)

used in a loop:
Code:
00.00.00.98
00.00.00.99
00.00.01.00
00.00.01.01


Supplying ALL relevant info (e.g. as requested by Don Cragun) REALLY helps people help you!
# 10  
Old 01-22-2017
Code:
[a=00.00.00.01]
[b=$(printf "%08d" $(( 10#${b//./} + 1 )) | fold -w2 | paste -sd.)]

am getting error in this
Code:
b=$(printf "%08d" $(( 10#${b//./} + 1 )) | fold -w2 | paste -sd.)
usage: paste [-s] [-d delimiters] file ...

---------- Post updated at 10:19 AM ---------- Previous update was at 10:18 AM ----------

yes am sorry am using bash

Last edited by Scrutinizer; 01-22-2017 at 11:22 AM.. Reason: code tags
# 11  
Old 01-22-2017
Try:
Code:
paste -sd. -

# 12  
Old 01-22-2017
But I want to read it from [a=00.00.00.12] and want to make that in next iteration
[b=00.00.00.13]

Last edited by rbatte1; 01-23-2017 at 06:19 AM.. Reason: Added ICODE tags and corrected grammar
# 13  
Old 01-22-2017
Adapting RudiC's suggestion
Code:
b=$(printf "%08d" $(( 10#${a//.} + 1 )) | fold -w2 | paste -sd. -)

# 14  
Old 01-22-2017
Got it worked thanks guys .. Next time if i want to do some thing on my own instead of posting here , where do i start to learn this stuff
.. really appreciate all your help..
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