I have a file Builder.java
, with lines like:
public class Builder{
@Override
public void setCallId(long value) {
set4ByteField(value, 48);
setLogtype(1);
setVerify("ABAB");
}
public void setOriginCallId(long value) {
set8ByteField(value, 52);
}
public void setDateTimeYear(int value) {
set2ByteField(value, 60);
}
...
Then I want to replace only numbers > 50 to number+1, keeping all else as it was. Result:
public class Builder{
@Override
public void setCallId(long value) {
set4ByteField(value, 48);
setLogtype(1);
setVerifyflag("ABAB");
}
public void setOriginCallId(long value) {
set8ByteField(value, 53);
}
public void setDateTimeYear(int value) {
set2ByteField(value, 61);
}
....
}
I tried my best but wrote scripts which do not work, like:
cat Builder.java | awk -F'[,)]' '$2>50 {print $2+1}' > Builder.java
set51ByteField
becomeset52ByteField
if it exists in the input? If there are cases where numbers you do NOT want converted can appear in your real files then include some in the example in your question. It's always much easier to match the text you do want and much harder to not match the text that you don't want. – Ed Morton Feb 4 at 2:47set51ByteField
shouldn't be converted toset52ByteField
. Thanks but I thought it's clear since i attachedawk -F'[,)]'
– masonshu Feb 4 at 9:04