My need is :
Want to change
docBase="/something/something/something"
to
docBase="/only/this/path/for/all/files"
I have some (about 250 files)xml files.
In FileOne it contains
<Context path="/PPP" displayName="PPP" docBase="/home/me/documents" reloadable="true" crossContext="true">
In File Two it contains
<Context path="/PPP" displayName="PPP" docBase="/usr/share/somethingelse" reloadable="true" crossContext="true">
etc..
I extracted it by using:
cat *.xml | awk /"Context path"/ | awk -F"docBase=" '{print $2}' | awk '{print $1}' | sed 's/\//\\\//g' | awk 'sub(".$", "")' | awk 'sub("^", "")'
Output:
/home/me/documents
/usr/share/somethingelse
Then I changed code to get :
cat *.xml | awk /"Context path"/ | awk -F"docBase=" '{print $2}' | awk '{print $1}' | sed 's/\//\\\//g' | awk 'sub(".$", "")' | awk 'sub("^", "")'
Output:
\/home\/me\/documents
\/usr\/share\/somethingelse
Now i Found all the strings to be replaced.
And now i am going to Replace all those by my string.
sed -ie 's/
`cat *.xml | awk /"Context path"/ | awk -F"docBase=" '{print $2}' | awk '{print $1}' | sed 's/\//\\\//g' | awk 'sub(".$", "")' | awk 'sub("^.", "")'`
/\/only\/this\/path\/for\/all\/files/g' *.xml
It throws an error
bash: syntax error near unexpected token `('
What mistake i did..??
OR
Is there any other way to do the same ??
I found http://www.unix.com/shell-programming-scripting/84109-replace-filename-full-path-using-sed.html already. But little confusion..
.