创建一个文件和一个文件夹

touch sss
mkdir d

test.sh

#!/bin/bash
echo "enter the name:"
read filename
if test -d $filename ; then
cd $filename
pwd
else
echo "it's not a directory!"
fi

执行

sudo chmod +x test.sh
./test.sh

输出

enter the name:
d
/home/xxx/Desktop/d

执行

./test.sh

输出

enter the name:
sss
it's not a directory!

shell 判断是否是目录的更多相关文章

  1. shell 判断文件、目录是否存在

    shell判断文件是否存在   1. shell判断文件,目录是否存在或者具有权限 2. #!/bin/sh 3. 4. myPath="/var/log/httpd/" 5. m ...

  2. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  3. shell判断文件,目录是否存在或者具有权限的代码

    核心代码 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的 ...

  4. shell判断文件,目录是否存在或者具有权限 (转载)

    转自:http://cqfish.blog.51cto.com/622299/187188 文章来源:http://hi.baidu.com/haigang/blog/item/e5f582262d6 ...

  5. shell判断文件,目录是否存在或者具有权限

    shell判断文件,目录是否存在或者具有权限  #!/bin/sh  myPath="/var/log/httpd/"  myFile="/var /log/httpd/ ...

  6. linux shell判断文件,目录是否存在或者具有权限

    在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFi ...

  7. shell判断文件是否存在

    转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...

  8. Linux shell判断文件和文件夹是否存在

    shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...

  9. shell判断条件是否存在

    1. shell判断文件,目录是否存在或者具有权限 2. #!/bin/sh 3. 4. myPath="/var/log/httpd/" 5. myFile="/var ...

随机推荐

  1. 【BZOJ1176】[Balkan2007]Mokia/【BZOJ2683】简单题 cdq分治

    [BZOJ1176][Balkan2007]Mokia Description 维护一个W*W的矩阵,初始值均为S.每次操作可以增加某格子的权值,或询问某子矩阵的总权值.修改操作数M<=1600 ...

  2. xp系统报错 windows explorer has encountered a problem and needs to close.We are sorry for the inconvenience

    xp系统遇到问题: 打开某个软件提示报错信息, windows explorer has encountered a problem and needs to close.We are sorry f ...

  3. rest_framework之序列化详解 06

    拿到所有的角色数据 1.urls.py 2.models.py  假设只有3个角色 3.views.py from api import models import json json只能序列化pyt ...

  4. importlib应用 - django

    背景 仿django的中间件的编程思想 用户可通过配置,选择是否启用某个组件/某个功能,只需要配置 eg:报警系统,发邮件,发微信 ... ( 根据字符串导入模块, 利用反射找到模块下的类,实例化.执 ...

  5. C#基础笔记(第九天)

    1.面向过程<-->面向对象面向过程:面向的是完成这件事儿的过程,强调的是完成这件事儿的动作. 面向对象:找个对象帮你做事儿.意在写出一个通用的代码,屏蔽差异. 每个人都有姓名,性别,身高 ...

  6. java的==和equal的区别(一)

    java的==和equal的区别 “==”是用来比较两个String对象在内存中的存放地址是否相同的.例如, 1 2 3 4 5 6 7 8 9 String test1 = "test&q ...

  7. mysql_escape_string — 转义一个字符串用于 mysql_query

    string mysql_escape_string ( string $unescaped_string ) 本函数将 unescaped_string 转义,使之可以安全用于 mysql_quer ...

  8. FTP服务器配置实践

    1.为linux系统分配IP地址:192.168.X.1/24,并重启网络服务,客户端XP系统IP地址为:192.168.X.2/24, 2.查询本机是否安装了vsftpd服务,结果显示未安装,挂载光 ...

  9. ZW团队:IN_OUT传播模型简介

    传统媒体,网络媒体的整合推广,我曾经提出过一个:Tn-Out模式 In-Out是NBA的篮球术语,你自己百度下 传统媒体承担"IN"的角色,负责传播的深度和建立公信力 网络媒体充当 ...

  10. 【android】开发笔记系列:行为篇

    1:键盘遮挡了输入框 在androidManifest.xml里,对应的activity里设置键盘模式 <activity android:name="活动名称" andro ...