#在此加上是不是目录的判断。
if [ "`ls -A $dir`" = "" ]; then
echo "$dir is empty"
else
echo "$dir is not empty"
fi #判断文件是否有执行权限
if [ ! -x "$file" ]; then
echo "can not be execute."
fi # 这里的-d 参数判断$myPath是否存在
if [ ! -d "$myPath"]; then
echo "file not exist."
fi # 这里的-f参数判断$myFile是否存在
if [ ! -f "$myFile" ]; then
touch "$myFile"
fi # 其他参数还有-n,-n是判断一个变量是否是否有值
if [ ! -n "$myVar" ]; then
echo "$myVar is empty"
exit
fi # 两个变量判断是否相等
if [ "$var1" = "$var2" ]; then
echo '$var1 eq $var2'
else
echo '$var1 not eq $var2'
fi

shell文件/路径处理的更多相关文章

  1. Linux中shell文件操作大全

    1.创建文件夹#!/bin/shmkdir -m 777 "%%1" 2.创建文件#!/bin/shtouch "%%1" 3.删除文件#!/bin/shrm ...

  2. Python第一天 安装 shell 文件

    Python第一天  安装  shell  文件 python里面一切都是对象 object 代码缩进:建议用四个空格来缩进,不要用tab键 安装 Linux自带python,windows需要下载m ...

  3. linux sed命令查询结果前后批量追加内容(html文件批量修改css,js等文件路径)

    1.需求:linux使用shell命令查询结果前后批量追加内容 例如:我需要在当前目录下所有的css文件路径前追加域名 我想的是用sed替换去实现,鲍哥的思路是用for循环 1.1方法1:鲍哥的for ...

  4. windows下的批处理bat文件和Linux下的shell文件的互相转换

    shell(Linux.Solaris) bat(windows) 含义 # rem 注释行 /[directory]/[directory]/.../[directory]/ [disk]:\[di ...

  5. Go path/filepath文件路径操作

    本文:https://books.studygolang.com/The-Golang-Standard-Library-by-Example/chapter06/06.2.html path:htt ...

  6. C#常见的文件路径Api

    我们经常有遇到要处理文件路径的需求,那么一般我们常见的有几种: 程序下面的文件 临时目录下的文件 获取程序下面的文件 首先我们创建了实例解决方案: 其中调用链是:Main.Shell->FooA ...

  7. [转载]有些shell文件中为啥要用$(cd “$(dirname $0)“; pwd),pwd它不香吗

    $(cd "$(dirname "$0")",pwd) 解析   xx.sh 文件内容如下: #!/bin/bash BIN_FOLDER=$(cd " ...

  8. 内核驱动编译之Makefile shell pwd路径问题

    一般我们在写Makefile的时候为了获取到当前Makefile所在的文件夹路径,会使用TopDIR ?= $(shell pwd)来定义,后续的文件路径都是基于此TopDIR基础上使用. 今天在移植 ...

  9. Oracle数据库文件路径变更

    环境:RHEL 6.4 + Oracle 11.2.0.3 情景一:只是部分普通数据文件迁移,可以在线操作. 1.将对应表空间offline,移动数据文件到新路径 2.数据文件alter databa ...

随机推荐

  1. Good Bye 2015B

    Problem B:http://codeforces.com/contest/611/problem/B B. New Year and Old Property 题意:问输入的年份a到b中转化为二 ...

  2. PHP htmlspecialchars() 函数

    定义和用法 htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体. 预定义的字符是: & (和号) 成为 & " (双引号) 成为 " ...

  3. uva 10069

    简单的dp 但是一个大数加法  套用了末位大牛的类模板 #include <cstdio> #include <cstring> #include <algorithm& ...

  4. 编写你的第一个 Django 程序 第2部分

    原地址:http://django-chinese-docs.readthedocs.org/en/latest/intro/tutorial02.html 本教程上接 教程 第1部分 . 我们将继续 ...

  5. 【leetcode】Word Break (middle)

    Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...

  6. POJ2187Beauty Contest

    http://poj.org/problem?id=2187 题意 :有一个农场有N个房子,问最远的房子相距多少距离 . 思路 :凸包,旋转卡壳,通过寻找所有的对锺点,找出最远的点对. #includ ...

  7. javascript数据变量类型判断(JS变量是否是数组,是否是函数的判断)

    function isArray(o) { return Object.prototype.toString.apply(o) === “[object Array]”;}function isFun ...

  8. *JRebel 热部署

    Jrebel是一套商业Java开发软件,可快速实现热部署,节省大量重启时间,提高开发效率. 去IDEA的插件官网下载插件:http://plugins.jetbrains.com/plugin/444 ...

  9. POJ3260——The Fewest Coins(多重背包+完全背包)

    The Fewest Coins DescriptionFarmer John has gone to town to buy some farm supplies. Being a very eff ...

  10. How to Send an HTTP Header With Every Request With Spring RestTemplate

    In Know Which Apps Are Hitting Your Web Service, I showed how to write a servlet filter that enforce ...