自动编译

(命令列第一个参数) $1 如果只等如X, 那就是变量没有内容,是空变量, 也
是用来测试命令列上有没有参数,例如

user@minix-nb:~$ cat a
#! /bin/bash

#if [ X$1 = X ]
if[/$1 = /1/ ]

then
echo "the first argu is empty"
else
echo "the first argu is $1"
fi
user@minix-nb:~$ ./a
the first argu is empty
user@minix-nb:~$ ./a 123
the first argu is 123
user@minix-nb:~$

 


if [ -f $home/$1]
1.if 条件判断关键字
2.[ ] 语法要求
3.-f 文件比较运算符,如果 filename为常规文件,则为真
4.$home 取变量的值,如果.sh文件里面没有该就是则会取用户系统变量!你可以在终端中执行一下 echo $home 看看是什么路径
5.$1 取输入的第一个参数.例: sh xxx.sh 111 那么此时 $1的值就是 111

   大小为0 的  执行 

# find / -type f -size 0 -exec ls -l {} \;

 

#!/bin/sh

if [ /$1/ = /all/ ];then

#查找当前目录 最小深度 类型 目录 如果查到 读到变量 LANGUAGE

 find . -mindepth 1 -typy d | while read LANGAGUE; do

    #如果是build目录 进入文件

    if[ -f "$LANGAGUE"/build ];then

      cd "$LANGAGUS"

      ./build all

      #返回上一级

      cd ..

    fi

    done

    elif [ /$1/ = /clearn/ ]; then

    find . -mindepth 1 -type d | while read LANGUAGE; do

      if [ -f  "$LANGUAGE" /build  ]; then

      cd "$LANGUAGE"

      ./build clean

      cd ..

    fi

  done

else 

echo "syntax :build all | clean "

fi

 

posted @ 2019-06-19 07:52  countryboy666  阅读(117)  评论(0编辑  收藏  举报