CShell 单词替换
我有一个简短的文本文件,其语法如下:
FileName: some name
Version: 3
Length: 45
hello, this is an irrelevant, unimportant text.
So is this line.
现在,我正在尝试编写一个脚本,用给定的新编号替换版本号。
有人知道怎么做吗?我真的不介意它很丑
,谢谢 乌迪
I have a short text file with the following syntax:
FileName: some name
Version: 3
Length: 45
hello, this is an irrelevant, unimportant text.
So is this line.
Now, I'm trying to write a script that replace the version number with a given new number.
Anyone knows how to? I really don't mind it to be ugly
thanks,
Udi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不直接使用 sed 呢?
Why not just use
sed
?我不知道如何在csh中做到这一点。然而,冒着被认为是那些一有机会就告诉您使用他们最喜欢的东西的烦人的风险,有比使用 csh 更好的方法。传统的 unix 命令
sed
擅长做这件事,或者像 Perl 这样的语言也很有用。应该这样做。
I don't know how to do it in csh. However, at the risk of coming across as one of those annoying people who tells you to use their favourite thing at every opportunity, there are better ways than using csh. The traditional unix command
sed
is good at this stuff, or a language like Perl is also useful.should do it.