hadoop-config.sh小看

# resolve links - $0 may be a softlink

this="$0"                 ===========================将hadoop-config.sh 文件所在的相对目录赋给this

while [ -h "$this" ]; do              =================================while的测试条件里 -h "$this" 表示判断“$this”这个文件是否是符号链接
  ls=`ls -ld "$this"`          ============================将$this下面的所有子文件或者目录赋给ls
  link=`expr "$ls" : '.*-> \(.*\)$'`           ===========================expr字符串匹配------见http://zhidao.baidu.com/question/218734332.html
  if expr "$link" : '.*/.*' > /dev/null; then
    this="$link"
  else
    this=`dirname "$this"`/"$link"
  fi
done

# convert relative path to absolute path
bin=`dirname "$this"`
script=`basename "$this"`
bin=`cd "$bin"; pwd`
this="$bin/$script"    ================================绝对路径

# the root of the Hadoop installation
export HADOOP_HOME=`dirname "$this"`/..  =========================hadoop的安装目录(绝对路径)

#check to see if the conf dir is given as an optional argument
if [ $# -gt 1 ]     ==========================$#是指变量总数
then
    if [ "--config" = "$1" ]
      then
          shift      
          confdir=$1        =================shift之后$1代表的是传进来的第二个变量也就是hadoop的conf的目录HADOOP_CONF_DIR
          shift
          HADOOP_CONF_DIR=$confdir
    fi
fi
 
# Allow alternate conf dir location.
HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}" ====================${a:-b}如果给定a,则取a,如果没有给定a,那么取b

#check to see it is specified whether to use the slaves or the
# masters file
if [ $# -gt 1 ]
then
    if [ "--hosts" = "$1" ]
    then
        shift
        slavesfile=$1
        shift
        export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
    fi
fi

你可能感兴趣的:(Linux,Hadoop,Work,Journal)