由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - 请问如何用awk修改文件里的内容?
相关主题
如何修改eps文件?Re: 有哪位大吓知道CXTERM下的中文文本编辑软件,请告知,不胜感激!
Read-only ubuntu (转载)土土的问: 置换一文本文件中某个字符,用什么命令实现
双面打印Vi显示?
how to print the last 2 columns of a text file?[转载] 卧春
Help about printing through network![转载] Re: 怎么在启动过程中设定启动后进入文本模式?
怎么才能让打印机认中文?新手急问:怎么打开一个大文件的前n行?
怎样用mail把某一文本文件发送给一个email地址?请教如何在文本文件中揪出来一段文字?
telnet 一问。关于双面打印
相关话题的讨论汇总
话题: awk话题: looptimes话题: define话题: 内容话题: print
进入Unix版参与讨论
1 (共1页)
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
1 (共1页)
进入Unix版参与讨论
相关主题
关于双面打印Help about printing through network!
UNIX上的nobody的环境变量是否可以设置? 该如何设置?怎么才能让打印机认中文?
如何显示出“*”怎样用mail把某一文本文件发送给一个email地址?
[转载] 简单问题 -- about shell scripttelnet 一问。
如何修改eps文件?Re: 有哪位大吓知道CXTERM下的中文文本编辑软件,请告知,不胜感激!
Read-only ubuntu (转载)土土的问: 置换一文本文件中某个字符,用什么命令实现
双面打印Vi显示?
how to print the last 2 columns of a text file?[转载] 卧春
相关话题的讨论汇总
话题: awk话题: looptimes话题: define话题: 内容话题: print