Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 用sed替换双引号散列_Bash_Shell - Fatal编程技术网

Bash 用sed替换双引号散列

Bash 用sed替换双引号散列,bash,shell,Bash,Shell,替换配置文件中的默认密码哈希时出现问题: sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "\$1\$mF86/UHC\$WvcIcXred6crBz2onWxyac."/' input.txt 我发现以下错误: sed:-e表达式#1,字符74:'s'的未知选项 作品: search pattern: default_password_crypted: "$1$mF86/UHC$WvcIcX2t6cr

替换配置文件中的默认密码哈希时出现问题:

sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "\$1\$mF86/UHC\$WvcIcXred6crBz2onWxyac."/' input.txt
我发现以下错误:

sed:-e表达式#1,字符74:'s'的未知选项

作品:

search pattern: default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "1234567890"/' input.txt
我需要如何为散列写入替换模式


thx

您需要在替换内容中转义文本
/
,因为它是分隔符:

sed -i 's/default_password_crypted: "[^"]*"/default_password_crypted: "\$1\$mF86\/UHC\$WvcIcXred6crBz2onWxyac."/' input.txt
或者简单地使用不同的字符,例如

sed -i 's,default_password_crypted: "[^"]*",default_password_crypted: "\$1\$mF86,UHC\$WvcIcXred6crBz2onWxyac.",' input.txt

您也不需要在替换中逃逸
$

thx m8 1st工作正常,我永远不会得到around regex,grrrr,但要更改$mF86,这是原始密码哈希字符串“$1$mF86/UHC$WvcIcX2t6crBz2onWxyac”。如果我将“$1$mmF86..”之后的“/”替换为“,”哈希是changed@manga我的意思是,如果您不想在模式/替换中转义它,您应该使用不同的分隔符,而不是
/