I'm facing an issue I'm not quite sure how to overcome. I have a large directory with hundreds of folders, all following the naming scheme a_b_x, with x being a random word. In every one of these folders there are 3 text files, all with a couple of strings containing a_b_x as well.I'm trying to rename all of the directories and change the strings inside the files from a_b_x to a_x, meaning the b_ is supposed to be removed. I hope to accomplish this with some sed wizardry, as manually editing all of the files would take several hours.I'd be very thankful for any help!
Recursively edit files based on parent directory's name
linux;regular expression;rename
You can use this command :for folder in $(ls); do    for file in $(ls $folder); do        sed -i 's/_b//' $folder/$file    done    mv $folder ${folder/_b/}doneFirst loop is browsing directories.Second loop is editing contents of files located in folders.After leaving second loop, first one is renaming folders.Another way for dealing with spaces in filenames which would be interpreted as IFS :ls | while read folder ; do ls $folder | while read file; do  sed -i 's/_b//' $folder/$file done mv $folder ${folder/_b/}done