How to increment version number in a shell script?

前端 未结 11 2078
执念已碎
执念已碎 2020-11-29 23:47

The following simple version control script is meant to find the last version number of a given file, increment it, run a given command with the newly created file (e.g., ed

11条回答
  •  星月不相逢
    2020-11-30 00:34

    Tired of bash? Why not try Perl?

    $ cat versions
    1.2.3.44
    1.2.3.9
    1.2.3
    9
    
    $ cat versions | perl -ne 'chomp; print join(".", splice(@{[split/\./,$_]}, 0, -1), map {++$_} pop @{[split/\./,$_]}), "\n";'
    1.2.3.45
    1.2.3.10
    1.2.4
    10
    

    Not quite in compliance with the requirement, of course.

提交回复
热议问题