批量重命名,把关键词放在前面,动作词放在后面

This commit is contained in:
Luk Lu
2022-04-01 09:55:38 +08:00
parent 1edf66b260
commit 4cd12adc62
30 changed files with 120 additions and 13 deletions

14
gogs-change-hook-path.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
echo "in [RepoRoot]/*/*/hooks/post-receive & pre-receive, gogs is hard-coded with full path such as /faronear/git/gogs, you need to replace it if the path is changed."
read -p "Enter old hook path: >> " OLDPATH
read -p "Enter new hook path: >> " NEWPATH
read -p "Enter repository root path: >> " REPOROOT
sed -i "s:$OLDPATH:$NEWPATH:g" `grep "$OLDPATH" -rl $REPOROOT/*/*/hooks/`
echo "Completed replacing $OLDPATH to $NEWPATH recursively in folder $REPOROOT"
# 参数 -i 代表在文件里直接替换。但发现在 MacOS 里这会报错,在 Debian 里没问题。
# 可以用 : 来取代 /,以避免大量出现 \/
# sed -i "s/\/home\/fon\//\/root\//g" `grep '/home/fon' -rl git.repo/*/*/hooks`