First of all, I am new to bash script, so forgive me if I make minor mistakes.
Here is my problem. I needed to download my company website. I am doing this with wgetno problems, but since some files have a character ?and windows do not like file names with ?, I had to create a script that renames the files and also updates the source code of all the files that cause the rename file.
For this, I use the following code:
find . -type f -name '*\?*' | while read -r file ; do
SUBSTRING=$(echo $file | rev | cut -d/ -f1 | rev)
NEWSTRING=$(echo $SUBSTRING | sed 's/?/-/g')
mv "$file" "${file//\?/-}"
grep -rl "$SUBSTRING" * | xargs sed -i '' "s/$SUBSTRING/$NEWSTRING/g"
done
This has 2 problems.
- It's too long, I waited more than 5 hours and still go.
- This seems to be an addition to the source code, because when I stop the script and look for changes, the URL repeats as 4 times (or more).
, 2 separete , , FYI, 3291 , wget, , bash