mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
update scripts
This commit is contained in:
parent
0c58f678fe
commit
0aafd7e706
@ -1,3 +0,0 @@
|
||||
# Shell 脚本实战
|
||||
|
||||
> 本目录的代码是本人在学习、开发中总结的一些面向实战的 Shell 代码。
|
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
current_dir=$(cd `dirname $0`;
|
||||
pwd)
|
||||
echo "当前目录是:${current_dir}"
|
||||
|
||||
parent_dir=$(dirname $(pwd))
|
||||
echo "父目录是:${parent_dir}"
|
3
codes/shell/示例脚本/README.md
Normal file
3
codes/shell/示例脚本/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Shell 脚本实战
|
||||
|
||||
> 本目录的代码是本人在学习、开发中收集、总结的一些面向实战的 Shell 脚本代码。
|
@ -1,5 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# Linux 系统用户管理
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
# 创建用户组
|
||||
groupadd elk
|
||||
# 创建新用户,-g elk 设置其用户组为 elk,-p elk 设置其密码为 elk
|
29
codes/shell/示例脚本/输入和输出/目录操作.sh
Normal file
29
codes/shell/示例脚本/输入和输出/目录操作.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user