Linux常用命令

1)tree 查看目录结构

找不到命令时,使用yum install tree进行安装

 

 2) grep 检索文件内容

grep -r "hadoop" /home/hadoop/test/  查看/home/hadoop/test/所有包含hadoop关键字的文件

 

在/home/hadoop/test/目录下递归查找所有.txt文件中的关键字key
grep -R --include="*.txt" "hadoop" /home/hadoop/test/
 
在/home/hadoop/test/ 目录下递归查找所有.txt文件中的关键字hadoop,显示所属行并将查找到的结果覆盖写入/root/t.txt中
grep -R -n --include="*.txt" "hadoop" /home/hadoop/test/ > /home/hadoop/test/res.log

查找zookeeper进程,过滤掉当前的grep
ps -ef | grep zookeeper | grep -v "grep"
 

 

 查找zookeeper进程,过滤掉当前的grep,获取进程号

 

  查找bst_agg_tkt_back_model_d.sh进程,过滤掉当前的grep,获取进程号并杀死

ps -ef |grep bst_agg_tkt_back_model_d.sh | grep -v 'grep' | awk '{print $2}' | xargs kill -9

 

posted @ 2020-10-21 15:52  楔子  阅读(125)  评论(0)    收藏  举报