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创建目录、遍历子目录的更多相关文章

  1. 【操作系统作业—lab1】linux shell脚本 遍历目标文件夹和所有文件 | 包括特殊字符文件名的处理

    要求:写一个linux bash脚本来查看目标文件夹下所有的file和directory,并且打印出他们的绝对路径. 运行command:./myDir.sh  input_path  output_ ...

  2. Linux shell循环遍历

    有时候需要紧急处理一些Excel列表中的数据,如提供一堆id列表,需要删除对应的表,一开始的办法是通过python pandas读取excel,然后拼接id元祖执行sql命令: 运维的同事说不用这么麻 ...

  3. shell脚本遍历子目录

    #!/bin/bashsource /etc/profile tool_path=/data/rsync_clientroot_path=/data/log ####yyyy-mm-dd¸ñʽdat ...

  4. LINUX SHELL脚本攻略笔记[速查]

    Linux Shell脚本攻略笔记[速查] 资源 shell script run shell script echo printf 环境变量和变量 pgrep shell数学运算 命令状态 文件描述 ...

  5. Linux shell 1-初步认识

    1.什么是linux linux是一种操作系统,它可划分为以下四部分 1.linux内核(Linux系统的核心,负责管理系统内存,硬件驱动,文件系统等) 2.GNU工具(一组软件工具,提供一些类UNI ...

  6. Linux Shell常用技巧

    转载自http://www.cnblogs.com/stephen-liu74/ 一.    特殊文件: /dev/null和/dev/tty Linux系统提供了两个对Shell编程非常有用的特殊文 ...

  7. Linux shell command学习笔记(一)

    Shell的种类有很多种,例如CSH,Bourne Shell,Korn Shell.在现在的大多数Linux发行版中,默认的Shell一般都是Bourne again shell(bash). &l ...

  8. Linux-(3)Linux Shell 使用

    三.Linux Shell 3.1 文件管理 3.1.1 ls 命令 显示指定工作目录下的内容及属性信息 ls 命令是Linux下最常用的指令之一.ls命令为英文单词 list 的缩写,正如英文单词 ...

  9. Linux shell脚本编程(三)

    Linux shell脚本编程 流程控制: 循环语句:for,while,until while循环: while CONDITION; do 循环体 done 进入条件:当CONDITION为“真” ...

随机推荐

  1. <Java><!!!><面试题>

    装箱 & 拆箱 public class Test03 { public static void main(String[] args) { Integer f1 = 100, f2 = 10 ...

  2. L252

    How often have you heard the saying, "Stop and smell the roses?" Odds are, you've come acr ...

  3. libusb示例

    #include <stdio.h> #include <libusb-1.0/libusb.h> #include <stdint.h> #include < ...

  4. linux之ls、ll

    ls == list,根据不同的选项,列举指定目录或文件的相关信息,是Unix/Linux下最常用的命令之一,cd到某一目录下后执行的第一个命令. ls命令格式:ls [OPTION]... [FIL ...

  5. mac下python2.7升级到3.6

    1. 前言 Mac系统自带python2.7,本文目的是将自带的python升级到3.6版本. 网上有本多的做法是让python2.7和python3.X两个版本共存,博主并不知道,是两版本共存好,还 ...

  6. G++ C++之区别

    1.遇到精度用C++ 2.G++内存超限,C++过了 其他都用G++

  7. es6 常用总结

    1.变量 let 声明的变量只在它所在的代码块有效,不允许重复声明 const 声明是一个只读的常量.一旦声明,常量的值就不能改变. const与let的作用域相同,只在声明所在的块级作用域内有效. ...

  8. [LeetCode&Python] Problem 541. Reverse String II

    Given a string and an integer k, you need to reverse the first k characters for every 2k characters ...

  9. easyui的DataGrid的单元格添加ProgressBar进度条

    网上的搜到的好多不能用,官方easy-ui使用进度条 <div id="p" class="easyui-progressbar" ></di ...

  10. Unity调用Windows对话框保存时另存为弹框

    Unity开发VR之Vuforia 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...