Skip to content

Commit 50b09e2

Browse files
committed
update codes
1 parent 8edc990 commit 50b09e2

10 files changed

Lines changed: 176 additions & 5 deletions

File tree

codes/linux/soft/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,14 @@ wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fa
233233
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash
234234
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash
235235
```
236+
237+
## FastDFS 安装
238+
239+
说明:
240+
241+
使用方法:执行以下任意命令即可执行脚本。
242+
243+
```sh
244+
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash
245+
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash
246+
```

codes/linux/soft/fastdfs-install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ nginx_version=1.16.0
4747
nginx_path=/opt/nginx
4848

4949
printf "${GREEN}>>>>>>>> install required libs.${RESET}\n\n"
50-
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
50+
yum install -y git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim unzip
5151

5252
# download and decompression
5353
mkdir -p ${path}
@@ -95,6 +95,7 @@ make && make install
9595
printf "${GREEN}>>>>>>>>> fastdfs 配置文件准备${RESET}\n"
9696
# 配置修改参考:https://github.com/happyfish100/fastdfs/wiki
9797

98+
mkdir -p /etc/fdfs
9899
cp ${path}/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
99100
cp ${path}/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
100101
cp ${path}/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

codes/shell/demos/variable-demo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

33
################### 声明变量 ###################
4-
word="hello"
5-
echo ${word}
4+
name="world"
5+
echo "hello ${name}"
66
# Output: hello
77

88
################### 只读变量 ###################
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
################### 声明变量 ###################
4+
name="world"
5+
echo "hello ${name}"
6+
# Output: hello world
7+
8+
################### 只读变量 ###################
9+
readonly_var="hello"
10+
echo ${readonly_var}
11+
# Output: hello
12+
readonly readonly_var
13+
# rword="bye" # 如果放开注释,执行时会报错
14+
15+
################### 删除变量 ###################
16+
dword="hello" # 声明变量
17+
echo ${dword} # 输出变量值
18+
# Output: hello
19+
20+
unset dword # 删除变量
21+
echo ${dword}
22+
# Output: (空)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
folder=$(pwd)
4+
echo "current path: ${folder}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo "User info fro userId:$USER"
4+
echo UID:$UID
5+
echo HOME:$HOME
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/bin/bash
2-
#testing variables
1+
#!/usr/bin/env bash
32

43
days=10
54
guest="Katie"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
# ----------------------------------------------------------------------------------
4+
# 根据特定字符将一个字符串分割成数组
5+
# ----------------------------------------------------------------------------------
6+
7+
str="0.0.0.1"
8+
OLD_IFS="$IFS"
9+
IFS="."
10+
array=(${str})
11+
IFS="$OLD_IFS"
12+
size=${#array[*]}
13+
lastIndex=`expr ${size} - 1`
14+
echo "数组长度:${size}"
15+
echo "最后一个数组元素:${array[${lastIndex}]}"
16+
for item in ${array[@]}
17+
do
18+
echo "$item"
19+
done
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
################### 单引号和双引号 ###################
4+
################### 拼接字符串 ###################
5+
# 使用单引号拼接
6+
name1='white'
7+
str1='hello, '${name1}''
8+
str2='hello, ${name1}'
9+
echo ${str1}_${str2}
10+
# Output:
11+
# hello, white_hello, ${name1}
12+
13+
# 使用双引号拼接
14+
name2="black"
15+
str3="hello, "${name2}""
16+
str4="hello, ${name2}"
17+
echo ${str3}_${str4}
18+
# Output:
19+
# hello, black_hello, black
20+
21+
################### 获取字符串长度 ###################
22+
text="12345"
23+
echo "${text} length is: ${#text}"
24+
# Output:
25+
# 12345 length is: 5
26+
27+
################### 获取字符串长度 ###################
28+
text="12345"
29+
echo ${text:2:2}
30+
# Output:
31+
# 34
32+
33+
################### 查找子字符串 ###################
34+
text="hello"
35+
echo `expr index "${text}" ll`
36+
# Output:
37+
# 3
38+
39+
################### 截取关键字左边内容 ###################
40+
full_branch="feature/1.0.0"
41+
branch=`echo ${full_branch#feature/}`
42+
echo "branch is ${branch}"
43+
44+
################### 截取关键字右边内容 ###################
45+
full_version="0.0.1-SNAPSHOT"
46+
version=`echo ${full_version%-SNAPSHOT}`
47+
echo "version is ${version}"
48+
49+
################### 判断字符串中是否包含子字符串 ###################
50+
result=$(echo "${str}" | grep "feature/")
51+
if [[ "$result" != "" ]] ; then
52+
echo "feature/ 是 ${str} 的子字符串"
53+
else
54+
echo "feature/ 不是 ${str} 的子字符串"
55+
fi
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
# 创建数组
4+
nums=([2]=2 [0]=0 [1]=1)
5+
colors=(red yellow "dark blue")
6+
7+
# 访问数组的单个元素
8+
echo ${nums[1]}
9+
# Output: 1
10+
11+
# 访问数组的所有元素
12+
echo ${colors[*]}
13+
# Output: red yellow dark blue
14+
15+
echo ${colors[@]}
16+
# Output: red yellow dark blue
17+
18+
printf "+ %s\n" ${colors[*]}
19+
# Output:
20+
# + red
21+
# + yellow
22+
# + dark
23+
# + blue
24+
25+
printf "+ %s\n" "${colors[*]}"
26+
# Output:
27+
# + red yellow dark blue
28+
29+
printf "+ %s\n" "${colors[@]}"
30+
# Output:
31+
# + red
32+
# + yellow
33+
# + dark blue
34+
35+
# 访问数组的部分元素
36+
echo ${nums[@]:0:2}
37+
# Output:
38+
# 0 1
39+
40+
# 访问数组长度
41+
echo ${#nums[*]}
42+
# Output:
43+
# 3
44+
45+
# 向数组中添加元素
46+
colors=(white "${colors[@]}" green black)
47+
echo ${colors[@]}
48+
# Output:
49+
# white red yellow dark blue green black
50+
51+
# 从数组中删除元素
52+
unset nums[0]
53+
echo ${nums[@]}
54+
# Output:
55+
# 1 2

0 commit comments

Comments
 (0)