Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to replace a word in all of my sub-directries,files globally within in a directory . Would like to get a suggestion from you and really appreciate for your help.
You have words in your directories? I only have files.
Do you want to rename files with certain names, or do you want to replace text inside files?
To be specific ...it's for my dream weaver directory. I have large number of directories and sub directries and files which consits of information related to web sites.So recently i changed name to one my directories for which i need to replace the name in the linked files.This i want to do globaally rather than going into individual file and changing them which is time consuming.
What linux distro and desktop environment are you using. I think XFCE desktop has some batch rename program. Search for something similar (I read somewhere pyRename or pyRenamer).
So I would suggest sed used with find and perhaps fed into a loop depending on the complexity of the change. This may sound a little vague, but so far, so has your description.
You will need to provide examples if you want more than suggested solution path?
To be specific ...it's for my dream weaver directory. I have large number of directories and sub directries and files which consits of information related to web sites.So recently i changed name to one my directories for which i need to replace the name in the linked files.This i want to do globaally rather than going into individual file and changing them which is time consuming.
An algorithm like this in a script should do the trick:
function replace_text($name)
if $name is a directory, then
{
for every $directory_entry in $name, do:
{
call replace_text($directory_entry)
}
done
}
else
{
# You may want to add some logic here to
# exclude certain files
sed --in-place=.bak "s/old-text/new-text/g" $name
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.