[英]what is meaning of sed -e 's|PATH="\(.*\)"|PATH="/opt/man/common/bin:\1"|g' -i /etc/environment line
以下命令是什么意思?
sed -e 's|PATH="\(.*\)"|PATH="/opt/man/common/bin:\1"|g' -i /etc/environment
它替換了所有的實例
PATH="somestring"
和
PATH="/opt/man/common/bin:somestring"
在文件/etc/environment
詳細地
s|string1|string2|
用string2
替換string1
|
)由替換命令 ( s
) 后面的字符定義。 更常見的是/
。g
告訴sed
替換所有不重疊的匹配項(而不僅僅是第一個匹配項)\(
和\)
定義一個組(在這種情況下,引號之間的所有內容)\1
是對第一組的反向引用-i
告訴sed
直接在文件中應用更改(內聯),而不是寫入標准輸出。編輯
正如評論中指出的那樣,這個正則表達式非常脆弱。
CDPATH="string"
'
分隔的字符串。 它不會匹配PATH='somepath'
。# some comment with PATH="" in the text
STRING='PATH="somepath"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.