Is there any way that i can increment some number in sed after pattern matching
suppose i have this file
201 AD BBH NN
376 AD HGH JU
I want to match the starting integers and then add the number 5 to it in sed
Is this possible
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re probably better off using a slightly more advanced tool, such as
awk:If you really must do it in
sedthen, yes, it can be done. But it’s butt-ugly. See here for a way of doing it:This particular script adds 1 to a number and you can now (hopefully) understand why I called it butt-ugly. Trying to do this with
sedis akin to trying to cut down a Karri tree with a goldfish.You should use the right tool for the job.