For replace the "name" word with the "something" word, use: sed "s/\(<username><\!\[[A-Z]*\[\)name\]/\1something/g" file.xml That is going to replace all the occurrences of the specified word. So far all is outputted to standard output, you can use: sed "s/\(<username><\!\[[A-Z]*\[\)name\]/\1something/g" file.xml > anotherfile.xml to save the changes to another file.