linux shell创建目录、遍历子目录
1、创建目录
代码1:
#!/bin/bash
#如果没有tmp_dir目录则创建
static_dir="/web/fyunw.com/static"
if [ ! -d $staic_dir ]; then
sudo mkdir -p -m 755 $static_dir
echo "sudo mkdir -p -m 755 ${static_dir} done"
fi
2、遍历子目录
代码2:
#!/bin/bash
static_dir="/web/fyunw.com/static"
for tmp_file in $(ls $static_dir)
do
echo $tmp_file
source_dir="${static_dir}/${tmp_file}/v1"
target_dir="/web_static/${tmp_file}/v1"
if [[ ! -d $source_dir && -d $target_dir ]]; then
sudo ln -s $target_dir v1
done
linux shell创建目录、遍历子目录的更多相关文章
- 【操作系统作业—lab1】linux shell脚本 遍历目标文件夹和所有文件 | 包括特殊字符文件名的处理
要求:写一个linux bash脚本来查看目标文件夹下所有的file和directory,并且打印出他们的绝对路径. 运行command:./myDir.sh input_path output_ ...
- Linux shell循环遍历
有时候需要紧急处理一些Excel列表中的数据,如提供一堆id列表,需要删除对应的表,一开始的办法是通过python pandas读取excel,然后拼接id元祖执行sql命令: 运维的同事说不用这么麻 ...
- shell脚本遍历子目录
#!/bin/bashsource /etc/profile tool_path=/data/rsync_clientroot_path=/data/log ####yyyy-mm-dd¸ñʽdat ...
- LINUX SHELL脚本攻略笔记[速查]
Linux Shell脚本攻略笔记[速查] 资源 shell script run shell script echo printf 环境变量和变量 pgrep shell数学运算 命令状态 文件描述 ...
- Linux shell 1-初步认识
1.什么是linux linux是一种操作系统,它可划分为以下四部分 1.linux内核(Linux系统的核心,负责管理系统内存,硬件驱动,文件系统等) 2.GNU工具(一组软件工具,提供一些类UNI ...
- Linux Shell常用技巧
转载自http://www.cnblogs.com/stephen-liu74/ 一. 特殊文件: /dev/null和/dev/tty Linux系统提供了两个对Shell编程非常有用的特殊文 ...
- Linux shell command学习笔记(一)
Shell的种类有很多种,例如CSH,Bourne Shell,Korn Shell.在现在的大多数Linux发行版中,默认的Shell一般都是Bourne again shell(bash). &l ...
- Linux-(3)Linux Shell 使用
三.Linux Shell 3.1 文件管理 3.1.1 ls 命令 显示指定工作目录下的内容及属性信息 ls 命令是Linux下最常用的指令之一.ls命令为英文单词 list 的缩写,正如英文单词 ...
- Linux shell脚本编程(三)
Linux shell脚本编程 流程控制: 循环语句:for,while,until while循环: while CONDITION; do 循环体 done 进入条件:当CONDITION为“真” ...
随机推荐
- L314 单音节词读音规则(二)-元音字母发音规则
1 单个元音发音尽量拖音一下(2S),发音会饱满一些. 2开音节: 辅音(辅组)(没有)+元音+辅音+e 的单词其中:元音发字母本身音,辅音字母不为r , 字母e不发音. 相对开音节:第一个元音都发字 ...
- L291
If you are currently in the midst of planning a wedding, then I don't need to tell you how stressful ...
- 关于索引的相关 day45
mysql数据库索引相关 一 介绍 什么是索引? 索引在MySQL中也叫做“键”,是存储引擎用于快速找到记录的一种数据结构.索引对于良好的性能非常关键,尤其是当表中的数据量越来越大时,索引对于性能 ...
- 【转载】 996是没前途的!996.ICU来了,回忆我对996的态度是如何从支持变成了怀疑!
原文地址: https://www.meiqiantu.com/20138.html --------------------------------------------------------- ...
- [LeetCode&Python] Problem 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...
- TP thinkphp 权限管理 权限认证 功能
(如有打扰,请忽略)阿里云ECS大羊群,2U4G低至1.4折,限实名新用户,需要的点吧https://promotion.aliyun.com/ntms/act/vm/aliyun-group/tea ...
- 动手动脑-Java的继承与多态
一. class Grandparent { public Grandparent() { System.out.println("GrandParent Created."); ...
- python django day 2
django-admin.py startproject zqxt_viewscd zqxt_viewspython manage.py startapp calczqxt_views/urls.py ...
- mvc core2.1 Identity.EntityFramework Core 导航状态栏(六)
之前做的无法 登录退出,和状态,加入主页导航栏 Views ->Shared->_Layout.cshtml <div class="navbar-collapse col ...
- 《DSP using MATLAB》Problem 6.24
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...