Created
September 28, 2020 04:16
-
-
Save jeiea/0fbab1eba87df53b8e8abbce26223458 to your computer and use it in GitHub Desktop.
Substitute string from all path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You shouldn't execute this if you didn't read it. | |
# If not installed | |
brew install sd | |
# Not effective commands | |
find . -ipath '*apple*' -type f | tac > source.txt | |
cat source.txt | sd 'apple' 'banana' | sd 'Apple' 'Banana' > dest.txt | |
paste -d" " source.txt dest.txt > replace.txt | |
# Effective commands | |
cat dest.txt | sd '.+' 'mkdir -p `dirname $0`' | zsh | |
cat replace.txt | sd '(\S+) (\S+)' 'mv $1 $2' | zsh | |
find . -ipath '*apple*' -exec rm -rf {} \; | |
rm source.txt dest.txt replace.txt | |
# For checking path completely removed | |
# find . -ipath '*apple*' | |
# For reverting changes | |
# find . -ipath '*banana*' -exec rm -rf {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment