find /data/ -regextype posix-extended -regex ".*\.(txt|shtml)" | xargs perl -pi -e 's|`http://[a-zA-Z0-9.]{1,26}.(test1.cn|test.com.cn|test3.cn)`|`https://[a-zA-Z0-9.]{1,26}.(test1.cn|test.com.cn|test3.cn)`|g'
我上面這個如何把替換的內容緩換成字串,是可以的,
但是是正則運算式,后面替換的內容不正確,應該怎么寫才對呢?
uj5u.com熱心網友回復:
find /data/ -regextype posix-extended -regex ".*\.(txt)" | xargs perl -pi -e "s|http://[a-zA-Z0-9.]{1,26}.test.cn|https://$1.test.cn|g"大師們,我這個為啥替換后。
http://11.test.cn/dfsfasfasf
http://11.test.cn/d12343
替換后變成
https://.test.cn/dfsfasfasf
https://.test.cn/d12343
里面的11不見了?該如何寫呢。
uj5u.com熱心網友回復:
1,加括號,([a-zA_Z0-9.]{1,26})2,我不確定perl的back reference使用$1還是\1
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/8344.html
標籤:系統維護與使用區
上一篇:CentOS7安裝eclipse之后無法新建任何專案怎么辦?
下一篇:kali linux
