-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jerry
committed
Aug 1, 2024
1 parent
5346e93
commit 2f2b55b
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
TARGET_DIR="/app/.output/public" | ||
# 遍历当前目录及子目录中的所有以 _ 开头的文件 | ||
find "$TARGET_DIR" -type f -name '_*' | while read -r file; do | ||
# 获取文件的目录和新文件名 | ||
dir=$(dirname "$file") | ||
new_file="${file/_/a}" | ||
|
||
# 重命名文件 | ||
mv "$file" "$new_file" | ||
|
||
# 更新所有引用到这个文件的地方 | ||
# 使用 sed 替换文件内容中的引用 | ||
find "$dir" -type f -exec sed -i "s|$file|$new_file|g" {} + | ||
done |