I have tried several variations with 'sed'
use Perl :)
#!/usr/bin/perl -p s/(\d+\.\d+\.\d+\.)(\d+)/$1${\($2-1)}/;
Usage:
$ ./decrement.pl infile >outfile
Update: alternatively, you could use the /e option, which treats the substitution part as Perl code (instead of as a double-quoted string):
s/(\d+\.\d+\.\d+\.)(\d+)/$1.($2-1)/e; # or (just to show another variant) s/(\d+\.\d+\.\d+\.)(\d+)/"$1".($2-1)/e;
In reply to Re: decrementing numbers
by almut
in thread decrementing numbers
by ddrew78
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |