Currently I need to remove a number from one line in a file, add 1 to that number and write to the previous number Using a bash in the same file, my line looks like this:
& lt; Server port = "8080" ... & gt;
And I call it & lt; Server port = "8081" ... & gt;
I know that - I can find the command "8080" and change it with something, I do not know how to actually get 8080 And it is converted to 8081. How can I do this?
Thanks in advance. /p>
If you need additional, then awk
is a better tool than Sed
.
Consider the file:
$ cat file & lt; Server port = "8080" ... & gt;
We can increase the port number like this:
$ awk -F \ "'/ & lt; server / {$ 2 ++} 1 This file was designed to work with sample input provided by you. Set how -
-F \ "
field separator to "
With this as the field separator, the port number is its own field.
-
/
Only the word server
.
-
{$ 2 ++}
For those selected lines, multiply another field by one.
-
1
This is a secret rhythm of awk for "Print All Rows."
No comments:
Post a Comment