杜龙少(sdvdxl)

Linux shell 命令

Word count: 100 / Reading time: 1 min
2016/05/25 Share

lsof

适用于ip4

1
lsof -Pnl +M -i4 | grep port

适用于ip6

1
lsof -Pnl +M -i6 | grep port

awk

杀掉名字一样的java进程

1
jps |grep SparkSubmit | awk '{print "kill -9 " $1}' | sh

如果仅仅是打印命令则后面的管道和sh不需要加如下

1
jps |grep SparkSubmit | awk '{print "kill -9 " $1}'

find

删除找到的符合条件的文件或者目录

1
find . -iname target -exec rm -rf {} \;

CATALOG
  1. 1. lsof
  2. 2. awk
  3. 3. find