批处理之家's Archiver

2565549687 发表于 2022-1-21 22:38

[已解决]我想请教一个关于Linux shell sed 字符串替换相关的问题?

[i=s] 本帖最后由 2565549687 于 2022-1-22 21:45 编辑 [/i]

在目录/root 下面有一个1.txt文本,以下是文本内容。[code]<div style="height:100%;position:fixed;top:0;left:0;right:0;background:#fff;z-index:10000000000">[/code]以下是我运行代码[code]sed -i "s/<div style="height:100%;position:fixed;top:0;left:0;right:0;background:#fff;z-index:10000000000">/888/g" ./1.txt[/code]我想通过sed的替换功能将1.txt文本内的内容替换成888
可是运行完代码发现没有任何的改变,
请问我哪里出错了呢?
请求大佬们帮忙看一下。
谢谢大家了。

Batcher 发表于 2022-1-22 20:23

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=250970&ptid=61423]1#[/url] [i]2565549687[/i] [/b]


    $safe_gdopen = ' 这个字符串是想表达什么意思?文本里面也没有啊

2565549687 发表于 2022-1-22 21:28

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=250997&ptid=61423]2#[/url] [i]Batcher[/i] [/b]


    不好意思,代码看多了眼花了。已经调整了一下,你说的那个是没有的,没有用。

2565549687 发表于 2022-1-22 21:44

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=250997&ptid=61423]2#[/url] [i]Batcher[/i] [/b][code]sed -i "s/<div style=\"height:100%;position:fixed;top:0;left:0;right:0;background:#fff;z-index:10000000000\">/888/g" ./1.txt[/code]多谢指点已经测试出正确的代码。
:victory:

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.