初学shell

遍历某一目录下的所有文件或文档,并输出

#!/bin/bash

for file in /home/linux/* 
do
    if [ -d "$file" ]
    then
        echo "$file is directory"
    elif [ -f "$file" ]
    then
        echo "$file is file"
    fi
done

 

-d前后都要有空格,不然无法识别命令

 

shell 中 sh 和 bash 的多行注释都是

:<<!

代码块

!

 

expr 2"+"3    不会输出计算结果

 

select 是bash中命令

但是头文件写  #!/bin/sh  也可以运行

select var in "linux""win""max""other"; do
    break;
done

字符串之间没有空格会被当成一个字符串

 

 

posted @ 2019-11-21 22:28  参婵  阅读(116)  评论(0编辑  收藏  举报