From 0aafd7e706610597c85755dbcfc0696b87fac279 Mon Sep 17 00:00:00 2001 From: Zhang Peng Date: Thu, 10 Oct 2019 14:16:45 +0800 Subject: [PATCH] update scripts --- codes/shell/action/README.md | 3 -- codes/shell/action/system/dir.sh | 8 ----- codes/shell/示例脚本/README.md | 3 ++ .../系统管理/系统用户管理.sh} | 5 ++++ codes/shell/示例脚本/输入和输出/目录操作.sh | 29 +++++++++++++++++++ .../输入和输出/读取选择参数.sh} | 0 6 files changed, 37 insertions(+), 11 deletions(-) delete mode 100644 codes/shell/action/README.md delete mode 100644 codes/shell/action/system/dir.sh create mode 100644 codes/shell/示例脚本/README.md rename codes/shell/{action/system/useradd.sh => 示例脚本/系统管理/系统用户管理.sh} (54%) create mode 100644 codes/shell/示例脚本/输入和输出/目录操作.sh rename codes/shell/{action/oper/input.sh => 示例脚本/输入和输出/读取选择参数.sh} (100%) diff --git a/codes/shell/action/README.md b/codes/shell/action/README.md deleted file mode 100644 index 5607683..0000000 --- a/codes/shell/action/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Shell 脚本实战 - -> 本目录的代码是本人在学习、开发中总结的一些面向实战的 Shell 代码。 diff --git a/codes/shell/action/system/dir.sh b/codes/shell/action/system/dir.sh deleted file mode 100644 index 8a3b2b7..0000000 --- a/codes/shell/action/system/dir.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -current_dir=$(cd `dirname $0`; -pwd) -echo "当前目录是:${current_dir}" - -parent_dir=$(dirname $(pwd)) -echo "父目录是:${parent_dir}" diff --git a/codes/shell/示例脚本/README.md b/codes/shell/示例脚本/README.md new file mode 100644 index 0000000..8838660 --- /dev/null +++ b/codes/shell/示例脚本/README.md @@ -0,0 +1,3 @@ +# Shell 脚本实战 + +> 本目录的代码是本人在学习、开发中收集、总结的一些面向实战的 Shell 脚本代码。 diff --git a/codes/shell/action/system/useradd.sh b/codes/shell/示例脚本/系统管理/系统用户管理.sh similarity index 54% rename from codes/shell/action/system/useradd.sh rename to codes/shell/示例脚本/系统管理/系统用户管理.sh index aefd2b7..84111a1 100644 --- a/codes/shell/action/system/useradd.sh +++ b/codes/shell/示例脚本/系统管理/系统用户管理.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +################################################################################### +# Linux 系统用户管理 +# @author: Zhang Peng +################################################################################### + # 创建用户组 groupadd elk # 创建新用户,-g elk 设置其用户组为 elk,-p elk 设置其密码为 elk diff --git a/codes/shell/示例脚本/输入和输出/目录操作.sh b/codes/shell/示例脚本/输入和输出/目录操作.sh new file mode 100644 index 0000000..81689be --- /dev/null +++ b/codes/shell/示例脚本/输入和输出/目录操作.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +################################################################################### +# 目录操作示例 +# @author: Zhang Peng +################################################################################### + +# 创建目录(整个文件路径中的目录如果不存在,都会一一创建,如果目录已存在,则什么也不做) +mkdir -p /home/linux-tutorial/temp + +# 进入目录 +cd /home/linux-tutorial/temp + +# 查看目录路径 +current_dir=$(pwd) +echo "当前目录是:${current_dir}" + +# 查看目录上一级路径 +parent_dir=$(dirname $(pwd)) +echo "父目录是:${parent_dir}" + +# 复制目录(复制 temp 目录所有内容,并命名新文件夹叫 temp2) +cp -rf /home/linux-tutorial/temp /home/linux-tutorial/temp2 + +# 移动目录(将 temp2 移到 temp 目录下) +mv /home/linux-tutorial/temp2 /home/linux-tutorial/temp/temp2 + +# 删除目录 +rm -rf /home/linux-tutorial diff --git a/codes/shell/action/oper/input.sh b/codes/shell/示例脚本/输入和输出/读取选择参数.sh similarity index 100% rename from codes/shell/action/oper/input.sh rename to codes/shell/示例脚本/输入和输出/读取选择参数.sh