${parameter/pattern/string} The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘*’, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list. Bash supports the $"..." quoting syntax to do locale-specific translation of the characters between the double quotes.
这里能解开我之前的一个疑惑:master怎么去启动slaves的。原来是通过ssh命令
Hadoop-config.sh
# resolve links - $0 may be a softlink this="$0" while [ -h "$this" ]; do ls=`ls -ld "$this"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then this="$link" else this=`dirname "$this"`/"$link" fi done
取个绝对地址也搞得这么蛋疼。取出链接 -> 后面的部分。如果带有/就是绝对路径链接?不对吧??不然就是相对链接,需要拼装上当前目录。果然是bug。https://issues.apache.org/jira/browse/HADOOP-7089 我用的是0.20.203版本。可以看看fix好的版本
# Resolve links ($0 may be a softlink) and convert a relative path # to an absolute path. NB: The -P option requires bash built-ins # or POSIX:2001 compliant cd and pwd. this="${BASH_SOURCE-$0}" common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P) script="$(basename -- "$this")" this="$common_bin/$script"
奇怪,在gnu的manual没到${BASH_SOURCE-$0} 这种 Shell Parameter Expansion,这里才有 坑爹啊-- 的作用是表示参数接收已结束
也就是说,比如
grep ---v file-v是内容,不是grep的参数了。man pwd ,找到
-P, --physical
avoid all symlinks
exec "$JAVA" -Dproc_$COMMAND $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
最终启动java class
相关阅读:
Hadoop datanode启动失败:Hadoop安装目录权限的问题
在Eclipse下搭建Hadoop开发环境各种问题的解决