Difference between revisions of "Sed"
From Blue-IT.org Wiki
(Created page with "== Save search and replace == search="$(printf "%s\n" "src=\"${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" replace="$(printf "%s\n" "src=\"${ANOTHER_DIR}/${SUBDIR}" | sed 's/[][\.*^$/...") |
(→Save search and replace) |
||
Line 1: | Line 1: | ||
== Save search and replace == | == Save search and replace == | ||
− | search="$(printf "%s\n" "src=\"${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" | + | search="$(printf "%s\n" "src=\"${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" |
− | replace="$(printf "%s\n" "src=\"${ANOTHER_DIR}/${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" | + | replace="$(printf "%s\n" "src=\"${ANOTHER_DIR}/${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" |
− | sed "s/${search}/${replace}/g" "${DOC}" | + | sed "s/${search}/${replace}/g" "${DOC}" |
Revision as of 20:27, 10 February 2012
Save search and replace
search="$(printf "%s\n" "src=\"${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" replace="$(printf "%s\n" "src=\"${ANOTHER_DIR}/${SUBDIR}" | sed 's/[][\.*^$/]/\\&/g')" sed "s/${search}/${replace}/g" "${DOC}"