shell 判断是否是目录
2024-09-10 13:46:06
创建一个文件和一个文件夹
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!
最新文章
- java.util.concurrent.atomic 包详解
- asp.net页面事件执行顺序
- java读取properties文件工具
- 这是啥-Cython语言简单介绍
- 第十五章:Android 调用WebService(.net平台)
- SQL对字符串数组的处理详解
- MSSQL 2008错误提示:更改对于登录sa失败
- mac svn的替代品CornerStone
- COCOS2D-X 精灵创建随笔
- Codeforces 231E - Cactus
- App适配iPhone 6/ Plus和iOS 8:10条小秘诀
- mysql-5.7.17.msi安装
- VSCode插件开发全攻略(四)命令、菜单、快捷键
- ubuntu 添加开机启动服务
- BZOJ 1042: [HAOI2008]硬币购物 (详解)(背包&;容斥原理)
- 一道颇有难度的JavaScript题
- 通过shell快速配置J2EE运行环境
- BZOJ3597 SCOI2014方伯伯运椰子(分数规划+spfa)
- 你真的会用Gson吗?Gson使用指南(4)
- 表单(同步提交)和AJAX(异步提交)示范