如何使用sed在目录下的所有文件中将windows路径更改为linux路径 [英] How to change a windows path to a linux path in all files under a directory using sed

查看:44
本文介绍了如何使用sed在目录下的所有文件中将windows路径更改为linux路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个目录结构从 windows 机器复制到 Linux 机器,我想使用 sed 将 c:\IBM\WebSphere 替换为 /opt/IBM/WebSpherecode> 在此目录下的所有文件中.

I copied a directory structure from a windows box to a Linux box and I would like to use sed to replace c:\IBM\WebSphere with /opt/IBM/WebSphere in all files under this directory.

有什么想法吗?

推荐答案

我觉得 sed 有点不方便,如果你想改变实际文件你可以使用 perl one-liner

I think sed is a little inconvenient for that purpose, if you want to change the actual files you can use perl one-liner

perl -pi -e 's/c:\\IBM\\/\/opt\/IBM\//g' *

根据需要添加或调整路径(如果您希望替换只更改这些目录,请添加 WebSphere)

Add or adjust the paths according to what you need (add WebSphere if you want the replacement to change only these dirs)

这篇关于如何使用sed在目录下的所有文件中将windows路径更改为linux路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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