v**t 发帖数: 25 | 1 我希望能自动修改文件里的内容?请问用awk能做到吗?我试了一下好像不行。
谢谢。 |
H********o 发帖数: 25 | 2 sed and awk can do the work.
please provide detail request.
【在 v**t 的大作中提到】 : 我希望能自动修改文件里的内容?请问用awk能做到吗?我试了一下好像不行。 : 谢谢。
|
v**t 发帖数: 25 | 3 比如一个文本文件test.txt,里面有一行:
#define looptimes 500
我想用awk更改 500, 让它每次自动加100。
我用变量的,但好像变量内容变了,文本内容没有变。
我的命令是:awk '/#define looptimes/ {$3 = $3+100; print} test.txt
【在 H********o 的大作中提到】 : sed and awk can do the work. : please provide detail request.
|
q*****m 发帖数: 73 | 4 awk(or sed) does not alter the original file. Use temp files to
store output:
awk '/#define looptimes/ {$3 = $3+100; print}' test.txt > newtest.txt
【在 v**t 的大作中提到】 : 比如一个文本文件test.txt,里面有一行: : #define looptimes 500 : 我想用awk更改 500, 让它每次自动加100。 : 我用变量的,但好像变量内容变了,文本内容没有变。 : 我的命令是:awk '/#define looptimes/ {$3 = $3+100; print} test.txt
|
v**t 发帖数: 25 | 5 谢谢。
请问还有没有别的方法,比如别的类似awk的命令,但可以改原文内容的?
【在 q*****m 的大作中提到】 : awk(or sed) does not alter the original file. Use temp files to : store output: : awk '/#define looptimes/ {$3 = $3+100; print}' test.txt > newtest.txt
|
v**t 发帖数: 25 | 6 这个命令只能输出要改的那一行到newtest.txt,而不是整个文档。
请问如何改动整个文档?谢谢。
【在 q*****m 的大作中提到】 : awk(or sed) does not alter the original file. Use temp files to : store output: : awk '/#define looptimes/ {$3 = $3+100; print}' test.txt > newtest.txt
|
c******r 发帖数: 38 | 7 awk '/#define looptimes/ {$3 = $3+100}{print}' test.txt
【在 v**t 的大作中提到】 : 这个命令只能输出要改的那一行到newtest.txt,而不是整个文档。 : 请问如何改动整个文档?谢谢。
|
v**t 发帖数: 25 | 8 Thanks a lot. It works now.
【在 c******r 的大作中提到】 : awk '/#define looptimes/ {$3 = $3+100}{print}' test.txt
|