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

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!

最新文章

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

热门文章

  1. zabbix安装配置2
  2. PHP移除json数据最右侧的逗号!
  3. Swap---hdu2819(最大匹配)
  4. 洛谷P2024 食物链 [NOI2001] 并查集
  5. nodejs Async详解之二:工具类
  6. PhotoSwipe中文API(一)
  7. (转)《SSO CAS单点系列》之 15分钟让你了解SSO技术到底是个什么鬼!
  8. POJ1236:Network of Schools(tarjan+缩点)?
  9. gitlab卸载
  10. C语言——stdio.h