cmd.exe是否有sed实用程序? [英] Is there any sed like utility for cmd.exe?

查看:79
本文介绍了cmd.exe是否有sed实用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Windows命令行( cmd.exe )以编程方式编辑文件内容。在* nix中,有 sed 用于此任务。

I want to programmatically edit file content using windows command line (cmd.exe). In *nix there is sed for this tasks. Is there any useful native equivalent in windows?

推荐答案

今天的powershell救了我。

Today powershell saved me.

对于 grep ,有:

get-content somefile.txt | where { $_ -match "expression"}

select-string somefile.txt -pattern "expression"

,对于 sed ,有:

get-content somefile.txt | %{$_ -replace "expression","replace"}

有关更多详细信息,请参见 Zain Naboulsis博客条目

For more detail see Zain Naboulsis blog entry.

这篇关于cmd.exe是否有sed实用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆