shell判断当前输入的名称是否为目录(shell学习笔记三)

来源:互联网 发布:720vr全景通 4.5 源码 编辑:程序博客网 时间:2024/06/14 10:42

[root@localhost shell_project]# ll
总用量 24
-rw-r--r--. 1 root root  49 8月  14 11:14 cshu.sh
-rw-r--r--. 1 root root 277 8月  15 15:41 info-df.sh
-rw-r--r--. 1 root root 203 8月  15 16:04 info-mulu.sh
-rw-r--r--. 1 root root 164 8月  15 14:49 info-root.sh
-rw-r--r--. 1 root root 326 8月  14 15:36 read.sh
drwxr-xr-x. 2 root root   6 8月  15 16:04 test
-rw-r--r--. 1 root root 131 8月  14 11:39 weizi.sh

[root@localhost shell_project]# vim info-mulu.sh


#!/bin/bash

#判断输入的名称是否为目录

read -t 30 -p "请输入文件名称:" dir

if [ -d "$dir" ]
  then
     echo "这个是$dir目录"
  else
    echo "找不到$dir这个目录"

fi




阅读全文
1 0
原创粉丝点击