由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - A question about awk
相关主题
How to redirect error messages to a file?how to print the last 2 columns of a text file?
请教How to get rid of the bg job id redirection?Help about printing through network!
Any idea on batch renaming files?how to turn off sendmail
a question about rename有关Unix shell script的问题
unix下编译fortran 的错误太多,看不到怎么办?Re: [转载] 一个很急迫的问题,谢谢
How to set environment variables for CGI scripts?How to use files with names like "-123.txt"?
Another simple questionhow to rename a bunch of files
双面打印help urgent!
相关话题的讨论汇总
话题: awk话题: logfile话题: 文件话题: question
进入Unix版参与讨论
1 (共1页)
c********e
发帖数: 417
1
用 awk 是不是只能读文件内容,而不能修改文件内容?
我用awk来实现把 backuptimes 加 1 的功能.我是这样写的:
awk '/backuptimes/{$2+=1;print}' logfile
print的结果是加 1 后的,但是文件的内容并没有改变,也就是没有加 1 .
难道awk不能改文件?
h******a
发帖数: 198
2
ft, redirection >

【在 c********e 的大作中提到】
: 用 awk 是不是只能读文件内容,而不能修改文件内容?
: 我用awk来实现把 backuptimes 加 1 的功能.我是这样写的:
: awk '/backuptimes/{$2+=1;print}' logfile
: print的结果是加 1 后的,但是文件的内容并没有改变,也就是没有加 1 .
: 难道awk不能改文件?

c********e
发帖数: 417
3
I'm not sure if redirection would work.
The logfile already exists, the > will not proceed. I can redirect to
a new file, remove the logfile, and rename the new file to logfile. But
I think it's not a good idea.
What's more,there are lots of other information in the logfile. I only
change the backuptimes. There is no need to redirect the whole file.
Thanks anyway.

【在 h******a 的大作中提到】
: ft, redirection >
m**u
发帖数: 5
4
use sed then.

【在 c********e 的大作中提到】
: I'm not sure if redirection would work.
: The logfile already exists, the > will not proceed. I can redirect to
: a new file, remove the logfile, and rename the new file to logfile. But
: I think it's not a good idea.
: What's more,there are lots of other information in the logfile. I only
: change the backuptimes. There is no need to redirect the whole file.
: Thanks anyway.

1 (共1页)
进入Unix版参与讨论
相关主题
help urgent!unix下编译fortran 的错误太多,看不到怎么办?
how to handle *.pkg files?How to set environment variables for CGI scripts?
Solars questionAnother simple question
格式问题双面打印
How to redirect error messages to a file?how to print the last 2 columns of a text file?
请教How to get rid of the bg job id redirection?Help about printing through network!
Any idea on batch renaming files?how to turn off sendmail
a question about rename有关Unix shell script的问题
相关话题的讨论汇总
话题: awk话题: logfile话题: 文件话题: question