Shell脚本备忘录

Windows

find port listened

netstat -ano | grep 8080

force kill process

taskkill /pid 123 /f

Linux

execute command every folder

find ./ -maxdepth 1 -type d | xargs -l {} mvn -f {} clean source:jar install
find ./ -type f -exec chmod 644 {} \;
find ./ -type d -exec chmod 755 {} \;

concat two audio files

ffmpeg -i aaa.m4a -i aaa.m4a -filter_complex concat=n=2:v=0:a=1 bbb.m4a

进入agenda容器

#!/bin/sh
container=`docker ps | grep agenda | awk '{print $1}'`
echo $container
docker exec -it $container sh

查看pm2的log

#!/bin/sh
id=$(pm2 l | grep $1 | awk '{print $4}')
echo $id
path=$(pm2 info $id | grep 'out log path' | awk '{print $6}')
echo $path
vim $path
# echo $path | xargs bash -c '</dev/tty vim "$@"' ignoreme

这个是查IP占用的连接数总数

sudo netstat -anpl |grep :37017 |awk '{print $5}' |awk -F: '{print $1}' |sort |uniq -c

这个是查连接到ip:port的进程的连接数

sudo netstat -anpl |grep 192.168.1.8:37017 |awk '{print $NF}' | awk -F/ '{print $1}' | sort | uniq -c