what is meaning of following command?
sed -e 's|PATH="\(.*\)"|PATH="/opt/man/common/bin:\1"|g' -i /etc/environment
CodePudding user response:
It substitutes all the instances of
PATH="somestring"
with
PATH="/opt/man/common/bin:somestring"
in the file /etc/environment
In detail
s|string1|string2|substitutesstring1withstring2- the delimiter (in this case
|) is defined by the character following the substitute command (s). More common is/. - the flag
gat the end tellssedto substitute all non-overlapping matches (and not only the first one) - the
\(and\)define a group (in this case everything between the quotes) - the
\1is a back-reference to the first group
- the delimiter (in this case
-iis tellingsedto apply the changes directly in the file (inline) instead of writing to standard output.
