I saw this question but I couldn't implement what I'm looking for.
Here is what I want:
- I have a file with a few lines ending with
4.1.01.97(same number for all lines - but number can change from time to time) - I want to open vim and change the number into another
I tried vim [file_name] +:%s/97/98/g +:wq which works fine but it wouldn't help if the file will change.
I next tried getting desired number with grep: cat [file_name] | tail -1 | grep -E '.[0-9][0-9]$'
I want to use the result of this in my vim command... Something like using vim [file_name] +:%s/97/98/g +:wq with the grep command inside ``, instead the 97.
How can I do that?
If this it possible without vim, that would also be helpful :)
Also, can my regular expression for the grep be improved?
This is how the file looks like:
A_,4.1.01.97
B_,4.1.01.97
C_,4.1.01.97
D_,4.1.01.97
E_,4.1.01.97
F_,4.1.01.97
G_,4.1.01.97
H_,4.1.01.97
This is how I want the file to look like:
A_,4.1.01.98
B_,4.1.01.98
C_,4.1.01.98
D_,4.1.01.98
E_,4.1.01.98
F_,4.1.01.98
G_,4.1.01.98
H_,4.1.01.98