Reputation: 57
How I pass the arguments to sed
command to replace a particular string . I want to replace 8080 with some different port like 8181
or 8282
.
grep -rl 8080 /tmp/standalone.xml | xargs sed -i 's/8080/8181/g'
Upvotes: 0
Views: 740
Reputation: 110
You can sed directly
sed -i "s/$oldValue/$newValue/g" /tmp/standalone.xml
or
sed -i "s/8080/8181/g" /tmp/standalone.xml
Upvotes: 0
Reputation: 27577
You want to use double quotes instead of single as variables can then be expanded, something like:
grep -rl 8080 /tmp/standalone.xml | xargs sed -i "s/8080/$port/g"
Upvotes: 1