-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange-url.sh
executable file
·55 lines (50 loc) · 1.08 KB
/
change-url.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
##################################
# Author : cndaqiang #
# Update : 2020-06-07 #
# Build : 2020-06-07 #
# What : 批量修改md文档中的](/in 为](/out #
##################################
sh=$0
in=$1
out=$2
file=$3
#---- in and out
if [ $2 ]
then
#----如果输入为none, 则不替换
if [ ${in} == ${out} ]
then
echo "in == out"
exit
fi
if [ ${in} == none ]
then
unset in
fi
if [ ${out} == none ]
then
unset out
fi
echo "Replace ](/${in} by ](/${out}/"
echo "sed -i s/\]\(\\/${in}/\]\(\\/${out}\\//g"
else
echo "Usage: $sh [out] [in] "
echo " to Replace ](/[in] by ](/[out]/ "
exit
fi
#---- File
if [ $file ]
then
file=($file)
else
file=$( find . | grep md )
fi
for i in ${file[@]}
do
echo "sed -i s/\]\(\\/${in}/\]\(\\/${out}\\//g $i"
sed -i s/\]\(\\/${in}/\]\(\\/${out}\\//g $i
sed -i s/\]\(\\/\\//\]\(\\//g $i
done
#echo ${in} ${out}
#sed -i s/\]\(${in}/\]\(${out}/g