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
(Edited as per your comment):
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.If you have mmv installed, you might try something like
mmv should be part of most distributions, but is not installed by default some cases. I'm not sure if it is in Ubuntu.