in reply to One liner to subtract by 2
perl -pe 's/([0-9]{10})$/sprintf "%010d",$1-2/e'
Update: I am not sure how to search for the line, though, because you did not give any information on how these lines are structured. Adding that to the one-liner is easy, e.g. let's pretend we want to process lines beginning with 0TONY:
perl -pe 's/([0-9]{10})$/sprintf "%010d",$1-2/e if /^0TONY/'
Update 2: sprintf added. Thanks derby.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One liner to subtract by 2
by derby (Abbot) on Jul 24, 2013 at 14:08 UTC | |
by choroba (Cardinal) on Jul 24, 2013 at 14:10 UTC | |
by Anonymous Monk on Jul 24, 2013 at 14:28 UTC | |
by choroba (Cardinal) on Jul 24, 2013 at 14:30 UTC |