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为“真” ...
随机推荐
- Zookeeper与Paxos
初识Zookeeper zookeeper为分布式应用提供了高效且可靠的分布式协调服务,提供了诸如统一命名服务.配置管理和分布式锁等分布式的基础服务. 在解决分布式数据一致性方面,zk没有直接采用Pa ...
- 2019-03-08 RF 调试Zibee 数据
- springboot (spring mvc)集成swagger
最近用springboot构建rest接口,考虑到最方便的验证接口,想到了引入swagger. 基本的步骤大致如下: 1.pom中引入swagger依赖: <dependency> < ...
- Codeforce 9C - Hexadecimal's Numbers
One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...
- Django组件之分页器
分页器 简单的分页器实现 views.py from django.core.paginator import Paginator,EmptyPage,PageNotAnInteger from ap ...
- Python网络爬虫第一弹《Python网络爬虫相关基础概念》
爬虫介绍 引入 之前在授课过程中,好多同学都问过我这样的一个问题:为什么要学习爬虫,学习爬虫能够为我们以后的发展带来那些好处?其实学习爬虫的原因和为我们以后发展带来的好处都是显而易见的,无论是从实际的 ...
- Samsung_tiny4412(驱动笔记02)----ASM with C,MMU,Exception,GIC
/**************************************************************************** * * ASM with C,MMU,Exc ...
- JAXB性能优化
前言: 之前在查阅jaxb相关资料的同时, 也看到了一些关于性能优化的点. 主要集中于对象和xml互转的过程中, 确实有些实实在在需要注意的点. 这边浅谈jaxb性能优化的一个思路. 案列: 先来构造 ...
- 【leetcode】58-LengthofLastWord
problem Length of Last Word 只有一个字符的情况: 最后一个word至字符串末尾之间有多个空格的情况: code1 class Solution { public: int ...
- display: table; 100%的宽度
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...