Q:

Text Processing

I have a few folders named folder1 folder2 etc.. under a root folder. In each folder there are many xml files. In each xml file there are number of occurence of text patern  (in case of under folder1) folder1.xxx folder1.yyy . I want to replace all the folder1.xxx with just xxx and folder2.yyy with yyy etc. 
I know first I need to get all the folder list and process each files under each folder and replace the texts accordingly. I using Ubuntu linux distro I tried sed but didnt succeed. Could you show me a qucik way to do this no matter whether it perl or bash or any other script. Thanks  

A:

(Edited as per your comment):
for dir in folder1 folder2; do
  sed -i "s/$dir\.//" $dir/*
done

What this will do is for each directory you list (the folder1 folder2 bit) it will do a simple "stream edit" (sed) on every file in that directory and search for the directory name followed by a dot and replace it with nothing.

