查看后台线程
ps -ef | grep spark
杀死进程
kill -9 pid
管道
who | wc -l
2
printf格式化输出
printf “this is ‘%s’\n” Hello World ni hao
this is ‘Hello’
this is ‘World’
this is ‘ni’
this is ‘hao’
printf “this is ‘%s’,’%s’\n” Hello World
this is ‘Hello’,’World’
重定向与管道
tr -d ‘a’ < nusers > nihaox
tr 先把nusers里面的 ‘a’删除 (用的ASICC),再将结果重定向到 文件 nihaox中
<< >>追加
< >覆盖
for f in dos-file*.txt
do
tr -d ‘\r’ < $f >>big-Unix-file.txt
done
一次循环体,就是一个文件
echo “starting master zookeeper”
/opt/zookeeper/bin/zkServer.sh start
echo “started master zookeeper”
cat /opt/sh/slaves | while read host
do
ssh “root@”$host nohup /opt/zookeeper/bin/zkServer.sh start > /dev/null 2>&1 &
done
**需要注意的是,通过循环读取 文件, 再通过ssh 连接其他机器,执行脚本的时候
就要,设置后台执行了,否则会造成后续主机脚本无法执行**