HI all,

am working on an opensource project(in Linux)..
I need to modify the string ,which is a part of the Folder,File,and others as such..

I have code to replace the string which is in content of the file....but i want the replacement to be done on the folder names and sub folders too....(and the main thing is some folders have extensions too)

Thank you

Recommended Answers

All 2 Replies

HI all,

am working on an opensource project(in Linux)..
I need to modify the string ,which is a part of the Folder,File,and others as such..

I have code to replace the string which is in content of the file....but i want the replacement to be done on the folder names and sub folders too....(and the main thing is some folders have extensions too)


For file contents, use sed:

sed -i.bak 's/original/replacement/' "$file"

For filenames, use the shell's parameter expansion:

filename=${filename/original/replacement}

hey i could replace the file content...but i want to chanege the folder names,subfolder names,file names......

There are lot many subfolders, and files too, so if my input is "root directory name" and "old string" and "relpace with" then replacements should take place at all places in one go...

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.