I have large config-files for an application. The lines have different structure, but some of them contains the parameter 'TIMEOUT=x', where x is an numeric value. I want to change the value for that specific paramater if the value is greater than a specific value (got that?). The timeout-parameter can be at different positions on different lines.
Example:
The file could look something like this:
# comment
KEYWORD=value KEYWORD="textstring"
KEYWORD value,value,value TIMEOUT=400
KEYWORD=value KEYWORD=value TIMEOUT=200 KEYWORD=value
# Another comment
KEYWORD=value TIMEOUT=100
And I want to change the TIMEOUT-value to 200 if the value is greater than 200. The result should look like this:
# comment
KEYWORD=value KEYWORD="textstring"
KEYWORD value,value,value TIMEOUT=200
KEYWORD=value KEYWORD=value TIMEOUT=200 KEYWORD=value
# Another comment
KEYWORD=value TIMEOUT=100
I know I can do this in a for-loop over all lines in the file, grep'ing and awk'ing out the value, echo'ing a new line in an if-else based on the value. The problem is that there are about 100 files with around 10000 lines each and it will take too long time to run a shell-loop.
Does anyone have any intelligent solution for this in awk or similar?