I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the number. How could this be done? Thanks in advance.
My files are structured like this:
crmopr 162756 tpiopr 102334 ddnope 210928
This one-liner does the jobs.
sed -i '/MATCHING_STRING/s/MATCHING_NUMBER/NEW_NUMBER/1' file
MATCHING_STRING: the string for finding the line i want to the change the number
MATCHING_NUMBER: the number that's going to be substituted
NEW_NUMBER: the new number
/1: change only first sustitution match in line (could be /g in this case too)
-i: makes changes permanent
Accepted solution which came seconds after I edited the OP also worked!