update codes

pull/11/head
Zhang Peng 2019-08-08 14:05:30 +08:00
parent 8edc990d02
commit 50b09e2743
10 changed files with 176 additions and 5 deletions

View File

@ -233,3 +233,14 @@ wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fa
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash
```
## FastDFS 安装
说明:
使用方法:执行以下任意命令即可执行脚本。
```sh
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash
```

View File

@ -47,7 +47,7 @@ nginx_version=1.16.0
nginx_path=/opt/nginx
printf "${GREEN}>>>>>>>> install required libs.${RESET}\n\n"
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
yum install -y git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim unzip
# download and decompression
mkdir -p ${path}
@ -95,6 +95,7 @@ make && make install
printf "${GREEN}>>>>>>>>> fastdfs 配置文件准备${RESET}\n"
# 配置修改参考https://github.com/happyfish100/fastdfs/wiki
mkdir -p /etc/fdfs
cp ${path}/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
cp ${path}/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
cp ${path}/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
################### 声明变量 ###################
word="hello"
echo ${word}
name="world"
echo "hello ${name}"
# Output: hello
################### 只读变量 ###################

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
################### 声明变量 ###################
name="world"
echo "hello ${name}"
# Output: hello world
################### 只读变量 ###################
readonly_var="hello"
echo ${readonly_var}
# Output: hello
readonly readonly_var
# rword="bye" # 如果放开注释,执行时会报错
################### 删除变量 ###################
dword="hello" # 声明变量
echo ${dword} # 输出变量值
# Output: hello
unset dword # 删除变量
echo ${dword}
# Output: (空)

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
folder=$(pwd)
echo "current path: ${folder}"

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "User info fro userId:$USER"
echo UID:$UID
echo HOME:$HOME

View File

@ -1,5 +1,4 @@
#!/bin/bash
#testing variables
#!/usr/bin/env bash
days=10
guest="Katie"

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------
# 根据特定字符将一个字符串分割成数组
# ----------------------------------------------------------------------------------
str="0.0.0.1"
OLD_IFS="$IFS"
IFS="."
array=(${str})
IFS="$OLD_IFS"
size=${#array[*]}
lastIndex=`expr ${size} - 1`
echo "数组长度:${size}"
echo "最后一个数组元素:${array[${lastIndex}]}"
for item in ${array[@]}
do
echo "$item"
done

View File

@ -0,0 +1,55 @@
#!/usr/bin/env bash
################### 单引号和双引号 ###################
################### 拼接字符串 ###################
# 使用单引号拼接
name1='white'
str1='hello, '${name1}''
str2='hello, ${name1}'
echo ${str1}_${str2}
# Output:
# hello, white_hello, ${name1}
# 使用双引号拼接
name2="black"
str3="hello, "${name2}""
str4="hello, ${name2}"
echo ${str3}_${str4}
# Output:
# hello, black_hello, black
################### 获取字符串长度 ###################
text="12345"
echo "${text} length is: ${#text}"
# Output:
# 12345 length is: 5
################### 获取字符串长度 ###################
text="12345"
echo ${text:2:2}
# Output:
# 34
################### 查找子字符串 ###################
text="hello"
echo `expr index "${text}" ll`
# Output:
# 3
################### 截取关键字左边内容 ###################
full_branch="feature/1.0.0"
branch=`echo ${full_branch#feature/}`
echo "branch is ${branch}"
################### 截取关键字右边内容 ###################
full_version="0.0.1-SNAPSHOT"
version=`echo ${full_version%-SNAPSHOT}`
echo "version is ${version}"
################### 判断字符串中是否包含子字符串 ###################
result=$(echo "${str}" | grep "feature/")
if [[ "$result" != "" ]] ; then
echo "feature/ 是 ${str} 的子字符串"
else
echo "feature/ 不是 ${str} 的子字符串"
fi

View File

@ -0,0 +1,55 @@
#!/usr/bin/env bash
# 创建数组
nums=([2]=2 [0]=0 [1]=1)
colors=(red yellow "dark blue")
# 访问数组的单个元素
echo ${nums[1]}
# Output: 1
# 访问数组的所有元素
echo ${colors[*]}
# Output: red yellow dark blue
echo ${colors[@]}
# Output: red yellow dark blue
printf "+ %s\n" ${colors[*]}
# Output:
# + red
# + yellow
# + dark
# + blue
printf "+ %s\n" "${colors[*]}"
# Output:
# + red yellow dark blue
printf "+ %s\n" "${colors[@]}"
# Output:
# + red
# + yellow
# + dark blue
# 访问数组的部分元素
echo ${nums[@]:0:2}
# Output:
# 0 1
# 访问数组长度
echo ${#nums[*]}
# Output:
# 3
# 向数组中添加元素
colors=(white "${colors[@]}" green black)
echo ${colors[@]}
# Output:
# white red yellow dark blue green black
# 从数组中删除元素
unset nums[0]
echo ${nums[@]}
# Output:
# 1 2