ps -ef | grep 'new-consumer' | awk '{print $2}' |xargs kill -9 #删除kafka consumer进程
ps -ef|grep java|grep -v grep|awk '{print $2}'|xargs kill -9 #删除java进程
find /opt/flume-custom/ -name *.conf|xargs grep -re "127.0.0.1:9092" #查找到的文件中查找指定字符串
find /opt/ -type f -name '*.log' |xargs grep 'db.hostname'
cat ~/.ssh/id_rsa.pub | ssh my_admin@111.111.111.111 "cat - >> ~/.ssh/authorized_keys"
kill -9 $(ps -ef|grep "sh\ *start_new.sh\ *main"|grep -v grep|awk '{print $2}') #\ *表任意多空格
kill -9 `ps -ef|grep data-integration|awk '{print $2}'`
ls|while read f;do zip -r ${f}.zip $f;done #压缩所有ls出来的文件夹
ls|grep 'hadoop-cmf-yarn-RESOURCEMANAGER-nn1.hadoop.com.log.out.[0-9]\{1,\}'|while read f;do cat /dev/null > $f;done #将所有RESOURCEMANAGER日志文件内容置为空,文件尾缀为1个以上从0到9的数字,如1、2、9、12均能匹配查找到,在nn1上磁盘(/var/log/{hadoop-hdfs,hadoop-yarn})上日志一般都比较大
# 查找10日前创建的文件,并情况其内容
find . -type f -name '*oozie-instrumentation.log.*' -atime +10 | while read f;do cat /dev/null > $f;done
#查看所有用户的crontab任务,其中"-I {}"参数,可以使用-i来等量实现
cat /etc/passwd | cut -f 1 -d : |xargs -I {} crontab -l -u {}
cat /etc/passwd | cut -f 1 -d : |xargs -i crontab -l -u {}
# 查询当前目录下所有文件(含目录下文件)中包含关键字(sku)的文件路径, 滤重, 并过滤掉路径中含指定字符(000)
grep -rn 'sku' * | awk -F ':' '{print $1}' | uniq | grep -v 000