Hi all,
I have a directory structure like "folder1/folder2/website_name/folder3/folder4/file.php."
I need to write a script which will enter into file.php and replace a particular string of characters with "website_name" folder name.
In folder2,there are many such website's folders kept.So script should grep for different website's folders name each time.Apart from "website_name" folder all the entities are common in mentioned directory/file structure.
I will appreciate if anyone will help me in getting through this.
Thanx in advance.
for file in `find /folder1 -type f -name "file.php" | xargs` # This will list ot the files and if file name is not static then use "*.php"
do
website=`echo "$file" | cut -d"\/" -f3` # Extract website name
sed -e 's/string/$website/g' $file # Substitute particular string with website name
done